:root {
  --bg: #f4f3ee;
  --surface: #ffffff;
  --text: #1b1d21;
  --muted: #646a73;
  --line: #dcdad2;
  --accent: #24449c;
  --accent-ink: #ffffff;
  --accent-soft: #e8ecf8;
  --warn-bg: #fff7e0;
  --warn-line: #ecd590;
  --warn-text: #5c4a12;
  --danger: #b3261e;
  --radius: 10px;
  --sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1b1e24;
    --text: #e9ebef;
    --muted: #9aa1ac;
    --line: #2d313a;
    --accent: #8ea6f2;
    --accent-ink: #0d1530;
    --accent-soft: #232b45;
    --warn-bg: #2c2713;
    --warn-line: #57491a;
    --warn-text: #ecd98f;
    --danger: #ff8f85;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

a { color: var(--accent); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* ───────── 머리말 · 꼬리말 */

.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; }
.logo { font-family: var(--mono); font-weight: 700; font-size: 20px; color: var(--text); text-decoration: none; letter-spacing: -0.02em; }
.logo b { color: var(--accent); }
.logo small { font-family: var(--sans); font-weight: 500; font-size: 13px; color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.site-header nav { display: flex; gap: 18px; font-size: 15px; white-space: nowrap; }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--text); }

.site-footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 28px 0 40px; color: var(--muted); font-size: 14px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
.site-footer a { color: var(--muted); }
.site-footer p { margin: 4px 0; }

main { padding: 28px 0 0; }

h1 { font-size: 30px; line-height: 1.3; margin: 0 0 10px; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: 21px; line-height: 1.35; margin: 40px 0 12px; letter-spacing: -0.01em; }
h3 { font-size: 17px; margin: 22px 0 6px; }
.lead { font-size: 17px; color: var(--muted); margin: 0 0 18px; max-width: 46em; }

.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }

.notice {
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-text);
  border-radius: var(--radius); padding: 12px 14px; font-size: 15px; margin: 0 0 22px; max-width: 60em;
}
.notice b { margin-right: 6px; }

/* ───────── 홈 */

.hero { padding: 26px 0 8px; }
.hero h1 { font-size: 36px; }
.hero .points { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 18px 0 0; list-style: none; }
.hero .points li { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 600; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.finder { margin: 26px 0 0; scroll-margin-top: 16px; }
.search {
  width: 100%; font: inherit; font-size: 17px; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 13px 16px; min-height: 52px;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.search::placeholder { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font-size: 15px; font-weight: 600; min-height: 38px;
}
.chips button span { margin-left: 4px; font-weight: 500; font-size: 13px; color: var(--muted); }
.chips button:hover { border-color: var(--accent); }
.chips button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips button.on span { color: inherit; opacity: .8; }
.chips button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.found { margin: 12px 0 0; min-height: 1.4em; font-size: 14.5px; color: var(--muted); }

.cat { scroll-margin-top: 16px; }
.cat h2 { margin: 30px 0 2px; }
.cat-desc { margin: 0; font-size: 14.5px; color: var(--muted); }
.cat .cards { margin-top: 12px; }
.none { margin: 30px 0; padding: 22px 20px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); }
.none p { margin: 4px 0; }
.none b { color: var(--text); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin: 26px 0 0; padding: 0; list-style: none; }
.cards a {
  display: block; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s;
}
.cards a:hover { border-color: var(--accent); transform: translateY(-2px); }
.cards strong { display: block; font-size: 19px; margin-bottom: 4px; }
.cards span { display: block; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.cards em { display: inline-block; margin-top: 12px; font-style: normal; font-size: 14px; font-weight: 600; color: var(--accent); }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; padding: 0; margin: 0; list-style: none; counter-reset: step; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; counter-increment: step; }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.steps b { display: block; }
.steps span { color: var(--muted); font-size: 14.5px; }

/* ───────── 작성 도구 */

.tool { display: grid; grid-template-columns: minmax(320px, 430px) minmax(0, 1fr); gap: 22px; align-items: start; }
.tool-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; margin-bottom: 10px; }
.tool-head h2 { margin: 0; font-size: 17px; }
.tool-head .mini { display: flex; gap: 6px; }
.tool-head .segs { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 14px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
legend { font-weight: 700; font-size: 15px; padding: 0; margin-bottom: 8px; color: var(--accent); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 10px; }
.field { grid-column: 1 / -1; min-width: 0; }
.field.half { grid-column: auto; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.field .opt { font-weight: 500; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; margin-left: 6px; }
.field input, .field textarea, .field select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 44px;
}
.field textarea { resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.hint { margin: 4px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.field .hint { min-height: 1em; }
.hint.warn { color: var(--danger); font-weight: 600; }
.hint.caution { margin-top: 10px; }

/* ───────── 서명 · 도장 설정 */

.seals > .hint { margin: 0 0 4px; }
.seal-ui { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 10px 12px 12px; margin-top: 8px; }
.seal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 14.5px; }
.seal-state { font-size: 13px; color: var(--muted); }
.seal-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.seal-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; font-size: 13.5px; }
.seal-opts label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.seal-opts input[type="range"] { width: 120px; accent-color: var(--accent); }
.seal-opts input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.seal-opts select { font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.btn.danger { color: var(--danger); }

.sign-dialog { width: min(92vw, 560px); border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: var(--surface); color: var(--text); }
.sign-dialog::backdrop { background: rgba(10, 12, 20, .55); }
.sign-dialog h2 { margin: 0 0 2px; font-size: 18px; }
.sign-canvas { display: block; width: 100%; aspect-ratio: 5 / 2; margin: 12px 0; background: #fff; border: 1px dashed #9aa1ac; border-radius: 10px; touch-action: none; cursor: crosshair; }
.sign-row { display: flex; gap: 8px; align-items: center; }
.sign-row .sp { flex: 1; }
.save-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

.badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600; vertical-align: middle; }
.badge.many { background: var(--warn-bg); color: var(--warn-text); }
.seg { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.seg span { margin-right: 2px; }
.seg button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; padding: 4px 9px; border-radius: 6px; min-height: 30px; }
.seg button.on { border-color: var(--accent); color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.safe { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }

button { font: inherit; cursor: pointer; }
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 10px 16px; font-weight: 600; font-size: 16px; min-height: 46px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 10px; font-size: 14px; min-height: 34px; font-weight: 500; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin: 16px -16px 0; padding: 12px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px); border-top: 1px solid var(--line);
}
.actions .btn.primary { flex: 1 1 150px; max-width: 280px; }
.actions .tip { font-size: 13px; color: var(--muted); flex: 1 1 260px; margin: 0; line-height: 1.45; }

#paper-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.paper { position: relative; width: 794px; min-height: 1123px; padding: 76px; background: #fff; color: #000; transform-origin: 0 0; }
.page-guide { position: absolute; left: 0; right: 0; border-top: 2px dashed #d0605a; pointer-events: none; }
.page-guide span { position: absolute; right: 10px; top: 4px; font: 600 13px/1.4 var(--sans); color: #b3261e; background: #fff; padding: 0 6px; }

.capture { position: absolute; left: -10000px; top: 0; width: 794px; padding: 0 76px; background: #fff; overflow: hidden; }

/* ───────── 문서 (화면 미리보기 · 인쇄 · PDF 공통) */
/* 크기는 모두 em으로 잡아, 글자 크기(작게·보통·크게)를 바꾸면 문서 전체가 함께 커지고 줄어든다. */

.doc {
  display: flow-root;
  font-family: "Nanum Myeongjo", "AppleMyungjo", "Batang", "바탕", "Noto Serif KR", serif;
  font-size: 15px; line-height: 1.8; color: #000; text-align: justify;
  word-break: normal; overflow-wrap: anywhere; line-break: strict;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.doc.ff-g { font-family: "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", sans-serif; }
.doc.fs-s { font-size: 13.5px; line-height: 1.72; }
.doc.fs-l { font-size: 16.5px; }

.doc p { margin: 0; }
.doc h1 { font-size: 2.2em; font-weight: 800; text-align: center; margin: .25em 0 1.5em; line-height: 1.3; letter-spacing: 0; }
.doc.ff-g h1 { font-weight: 700; }
.doc h2 { font-size: 1.06em; font-weight: 700; text-align: left; margin: 1.7em 0 .35em; letter-spacing: 0; }

.doc table.info { width: 100%; table-layout: fixed; border-collapse: collapse; border: 1.5px solid #000; margin: 0 0 1.15em; }
.doc table.info th, .doc table.info td { border: 1px solid #000; padding: .5em .75em; vertical-align: middle; text-align: left; font-weight: 400; }
.doc table.info th { background: #f2f2f2; padding: .5em .25em; text-align: center; font-weight: 700; white-space: nowrap; }
.doc col.c-side { width: 5.2em; }
.doc col.c-label { width: 7.2em; }
.doc col.c-short { width: 10.5em; }
.doc table.info th.top { vertical-align: top; }
.doc td.tall { height: 7em; vertical-align: top; }
.doc td.amount { font-size: 1.2em; font-weight: 700; }
.doc td.strong { font-weight: 700; }

.doc .stmt { margin: 1.5em 0; text-indent: 1em; }
.doc .stmt.center { margin: 2.4em 0; text-align: center; text-indent: 0; line-height: 2.05; }
.doc .daeum { margin: 1.4em 0 1.1em; text-align: center; font-weight: 700; }
.doc .body { margin: 1.4em 0; }
.doc .date { margin: 3em 0 2em; text-align: center; font-size: 1.1em; }
.doc .signer { margin: .6em 0; text-align: right; font-size: 1.1em; }
.doc .signer .role { margin-right: 1.6em; }
.doc .signer .nm { margin-right: 1.1em; font-weight: 700; }
.doc .to { margin-top: 3em; text-align: left; font-size: 1.3em; font-weight: 800; }
.doc.ff-g .to { font-weight: 700; }
.doc .to-top { margin-bottom: 1.2em; text-align: left; font-size: 1.2em; font-weight: 700; }

.doc .blank { display: inline-block; min-width: 7.5em; height: 1.25em; border-bottom: 1px solid #000; vertical-align: bottom; }
.doc .blank.l { min-width: 14em; }
.doc .blank.sign { min-width: 8em; }
.doc .gap { display: inline-block; width: 2em; }
.doc .gap.w { width: 3.4em; }
.doc .lines div { height: 2.2em; border-bottom: 1px solid #999; }

.doc .seal-slot { position: relative; display: inline-block; white-space: nowrap; text-indent: 0; }
.doc .seal-slot.right { float: right; color: #555; font-size: .88em; }
.doc .seal-slot.sign { height: 1em; }
.doc .signer .seal-slot.on { margin-right: 1.2em; }
.doc .signer .seal-slot.on.sign { margin-right: 0; }
.doc img.stamp { position: absolute; left: 50%; top: 50%; max-width: none; opacity: .93; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
.doc img.stamp.sign { opacity: 1; }
.doc img.stamp.dragging { cursor: grabbing; outline: 1px dashed #24449c; outline-offset: 3px; }

/* ───────── 안내 글 */

.prose { max-width: 46em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 8px 0; }
.prose li { margin: 6px 0; }
.prose dt { font-weight: 700; margin-top: 16px; }
.prose dd { margin: 4px 0 0; color: var(--muted); }
.prose p { margin: 10px 0; }

.report { max-width: 46em; margin: 28px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14.5px; color: var(--muted); }

.others { margin-top: 44px; }
.others ul { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 10px 0 0; list-style: none; }
.others a { display: block; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; text-decoration: none; color: var(--text); font-size: 15px; }
.others a:hover { border-color: var(--accent); color: var(--accent); }

.ad { margin: 28px 0; min-height: 90px; text-align: center; }
.partner { margin: 32px 0; }
.partner .disclosure { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ───────── 좁은 화면 */

@media (max-width: 900px) {
  .tool { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 26px; }
  .hero h1 { font-size: 29px; }
  .logo small { display: none; }
}

/* ───────── 인쇄: 문서만 출력 */

#print-root { display: none; }

@page { size: A4; margin: 0; }

@media print {
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  /* 한 장 = A4 한 쪽. 쪽 나눔은 app.js가 정한 위치를 그대로 쓴다 */
  .print-page { box-sizing: border-box; width: 210mm; height: 297mm; overflow: hidden; break-after: page; page-break-after: always; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-clip { box-sizing: border-box; padding-left: 76px; overflow: hidden; }
  .print-clip > .doc { width: 642px; }
  .doc { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
