:root {
  --bg: #101318;
  --panel: #171b22;
  --panel-2: #1d222b;
  --line: #2b323d;
  --text: #d9dee6;
  --text-strong: #f4f6f9;
  --muted: #9aa4b2;
  --accent: #e5483b;
  --accent-ink: #1a0f0e;
  --focus: #ffb4ab;
  --mono: ui-monospace, "D2Coding", "SFMono-Regular", Consolas, monospace;
  --sans: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.7 var(--sans); min-height: 100vh; display: flex; flex-direction: column;
}
a { color: inherit; }
a:hover { color: var(--text-strong); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { color: var(--text-strong); line-height: 1.3; }
h1 { font-size: 1.9rem; margin: .4em 0 .3em; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin: 2.2em 0 .6em; }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 레이아웃 (PC 1440px 이상에서 좌우 광고 영역 확보) ---------- */
.frame { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; display: block; }
.ad-slot { display: none; }
.ad-inline { display: block; margin: 28px auto; max-width: 728px; }
.ad-inline:empty { display: none; }
.ad-slot ins.adsbygoogle { display: block; }
.frame.has-ads > .ad-slot ins.adsbygoogle { width: 160px; min-height: 600px; }
.ad-slot ins.adsbygoogle[data-ad-status="unfilled"] { display: none; }
.ad-inline.ad-on { min-height: 100px; }   /* 광고가 늦게 떠서 본문이 밀리는 현상(CLS) 방지 */
.ad-inline.ad-on:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
.ad-slot.ad-on::before { content: "광고"; display: block; margin-bottom: 4px; font-size: .7rem; line-height: 1; color: var(--muted); text-align: center; }
@media (min-width: 1440px) {
  .frame.has-ads { max-width: 1520px; display: grid; grid-template-columns: 160px minmax(0, 1fr) 160px; gap: 24px; }
  .frame.has-ads > .ad-slot { display: block; position: sticky; top: 24px; align-self: start; min-height: 600px; }
}
.wrap { min-width: 0; padding-bottom: 48px; }

/* ---------- 헤더 / 푸터 ---------- */
.site-header { border-bottom: 1px solid var(--line); }
.site-header .inner { max-width: 1180px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.logo { font-family: var(--mono); font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--text-strong); display: inline-flex; gap: 8px; align-items: center; }
.logo svg { width: 22px; height: 22px; }
.header-note { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.site-footer { border-top: 1px solid var(--line); margin-top: 24px; padding: 22px 0 34px; font-size: .88rem; color: var(--muted); }
.site-footer .inner { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.foot-links { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 0; }
.foot-links li { display: flex; align-items: center; padding: 6px 0; }
.foot-links li + li::before { content: "·"; margin: 0 .7em; color: var(--line); }
.foot-links a { text-decoration: none; }
.foot-links a:hover { text-decoration: underline; }
.foot-note { margin: 0; font-size: .8rem; }

/* ---------- 공통 컴포넌트 ---------- */
.back { display: inline-block; margin: 28px 0 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 4px; font-family: var(--mono); font-size: .78rem; color: var(--muted); text-decoration: none; }
.back:hover { border-color: var(--muted); color: var(--text-strong); }
.lead { color: var(--muted); margin: 0 0 1em; max-width: 46em; }
.sub-mono { font-family: var(--mono); font-size: .78rem; color: var(--muted); margin: 0 0 1.6em; }
.pill { display: inline-block; font-family: var(--mono); font-size: .78rem; border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; color: var(--muted); }
.btn { font: inherit; font-weight: 700; cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); color: var(--text-strong); border-radius: 6px; padding: 9px 14px; min-height: 44px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.mini { font: inherit; font-size: .82rem; cursor: pointer; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 6px; padding: 6px 10px; min-height: 36px; }
.mini:hover { color: var(--text-strong); border-color: var(--muted); }
.mini.add { margin-top: 6px; }
.prose { max-width: 46em; }
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose h2 { margin-top: 1.8em; }
.prose .note { color: var(--muted); font-size: .9rem; }
.email-img { display: block; height: 26px; width: auto; margin: 6px 0 4px; }

/* ---------- 홈 (시안 E: 나무 에디토리얼) ---------- */
body[data-page=home] {
  --bg: #15281f; --panel: #1b3226; --panel-2: #1f3a2c; --line: #36513f;
  --text: #d6cfba; --text-strong: #f6eedb; --muted: #bdb6a1;
  --accent: #e8b44a; --accent-ink: #1d1706; --focus: #ffe2a3;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "AppleMyungjo", "Batang", "Songti SC", serif;
}
body[data-page=home] .logo { font-family: var(--serif); color: var(--accent); }
body[data-page=home] .hero h1 { font-family: var(--serif); }
.hero { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-end; justify-content: space-between; padding: 40px 0 44px; border-bottom: 1px solid var(--line); }
.hero h1 { flex: 1 1 520px; min-width: 0; margin: 0; font-weight: 900; font-size: 7rem; line-height: 1.05; letter-spacing: -.04em; }
.hero h1 span { display: block; }
.hero-side { flex: 0 1 380px; min-width: 260px; padding-bottom: 10px; }
.hero .lead { margin: 0 0 20px; font-size: 1.05rem; line-height: 1.75; }
.search { margin: 0; }
.search input[type=search] { width: 100%; min-height: 52px; padding: 0 16px; background: transparent; border: 0; border-bottom: 2px solid var(--accent); border-radius: 0; color: var(--text-strong); font: inherit; font-size: 1.05rem; }
.search input[type=search]::placeholder { color: var(--muted); }
.count { font-family: var(--mono); font-size: .78rem; color: var(--muted); margin: 10px 0 0; }
.group { display: flex; flex-wrap: wrap; gap: 20px 40px; padding: 28px 0; border-bottom: 1px solid var(--line); }
.group-head { flex: 0 0 240px; }
.group-head h2 { margin: 0; font-family: var(--serif); font-size: 1.6rem; color: var(--accent); }
.group-head p { margin: 6px 0 0; font-size: .9rem; color: var(--muted); }
.grid { flex: 1 1 520px; min-width: 0; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 32px; }
.card a { display: block; min-height: 44px; padding: 10px 0; text-decoration: none; }
.card a:hover h3 { color: var(--accent); }
.card h3 { margin: 0; font-family: var(--serif); font-size: 1.25rem; }
.card p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.home-note { margin: 28px 0 0; color: var(--muted); font-size: .9rem; max-width: 46em; }
.empty { color: var(--muted); padding: 24px 0; }

/* ---------- 서식 도구 ---------- */
.tool { margin: 18px 0 8px; display: grid; gap: 18px; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.form-panel { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.field { margin: 0 0 14px; }
.field label { display: block; font-weight: 700; font-size: .88rem; margin-bottom: 5px; }
.field.check { display: flex; align-items: center; gap: 10px; }
.field.check label { margin: 0; font-weight: 600; }
.field input[type=text], .field input[type=date], .field input[type=time], .field select, .field textarea, .rows input {
  width: 100%; min-height: 44px; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text-strong); font: inherit; font-size: 1rem;
}
.field textarea { resize: vertical; }
.field input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.row-line { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, .6fr) minmax(0, 1fr) auto; gap: 6px; margin-bottom: 6px; }
.row-line input { min-width: 0; padding: 8px; }
.autosave { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .84rem; color: var(--muted); }
.autosave input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.warns .warn { margin: 0 0 8px; padding: 9px 12px; border: 1px solid #7a3b34; background: #2a1816; color: #ffd0cb; border-radius: 8px; font-size: .88rem; }
.infos .info { margin: 0 0 8px; padding: 9px 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); border-radius: 8px; font-size: .88rem; }
.paper-wrap { background: #0b0d11; padding: 18px; border-radius: 8px; overflow: auto; }
.tool-tabs { display: none; }

/* 내 정보 프로필 */
.profile { margin: 0 0 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.profile summary { cursor: pointer; padding: 11px 14px; font-weight: 700; font-size: .92rem; min-height: 44px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.profile summary span { font-weight: 400; font-size: .8rem; color: var(--muted); }
.profile-body { padding: 4px 14px 14px; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.profile-actions .btn { padding: 8px 12px; min-height: 40px; font-size: .9rem; }
/* 종이 */
.paper { background: #fff; color: #111; width: 100%; max-width: 794px; min-height: 560px; margin: 0 auto; padding: 44px 44px 48px; font-size: 14px; line-height: 1.75; box-shadow: 0 6px 30px rgba(0,0,0,.45); }
.paper .doc-title { color: #111; text-align: center; font-size: 26px; letter-spacing: .08em; margin: 0 0 26px; }
.paper .center { text-align: center; }
.paper p { margin: 0 0 10px; }
.paper .body-text { margin: 14px 0; }
.paper .small { font-size: 12px; color: #444; }
.paper .clause { margin: 0 0 9px; }
.paper .doc-table { width: 100%; border-collapse: collapse; margin: 10px 0 14px; }
.paper .doc-table th, .paper .doc-table td { border: 1px solid #333; padding: 6px 9px; vertical-align: middle; }
.paper .doc-table th { background: #f1f1f1; text-align: center; width: 22%; font-weight: 700; }
.paper .doc-table.items th { width: auto; }
.paper .doc-table th.side { width: 12%; }
.paper .doc-table.parties td, .paper .doc-table.parties th { font-size: 12.5px; }
.paper .r { text-align: right; }
.paper .c { text-align: center; }
.paper .blank { border-bottom: 1px solid #555; }
.paper .v { border-bottom: 1px solid transparent; }
.paper .note-box { border: 1px solid #333; padding: 9px 11px; }
.paper .note-box.tall { min-height: 110px; }
.paper .q-title { font-size: 15px; margin: 20px 0 4px; color: #111; }
.paper .sum-line { margin: 12px 0; font-size: 15px; }
.paper .sign-line, .paper .to-line { text-align: right; margin-top: 16px; }
.paper .date-line { margin: 28px 0 12px; }
.paper .msg p { margin-bottom: 14px; }
.paper .msg p:last-child { text-align: right; }

/* ---------- 문의 폼 ---------- */
.contact-form { max-width: 640px; }
.contact-form .field input, .contact-form .field textarea { background: var(--panel); }
.contact-form textarea { min-height: 170px; }
.help { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }
.status { min-height: 1.6em; margin: 12px 0 0; color: var(--focus); }
.fallback { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--muted); font-size: .9rem; }
.contact-form .btn.primary { width: 100%; margin-top: 4px; }

/* ---------- 설명 섹션 ---------- */
.info-sec { max-width: 46em; }
.info-sec li { margin-bottom: .4em; }
.faq dt { font-weight: 700; color: var(--text-strong); margin-top: 1em; }
.faq dd { margin: .3em 0 0; color: var(--text); }
.disclaimer { margin-top: 2em; padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--panel); color: var(--muted); font-size: .88rem; max-width: 46em; }
.related { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.related a { display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; font-size: .9rem; color: var(--muted); }
.related a:hover { color: var(--text-strong); border-color: var(--muted); }

/* ---------- 모바일 ---------- */
@media (max-width: 900px) {
  h1 { font-size: 1.6rem; }
  .hero h1 { font-size: 4.2rem; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .group-head { flex-basis: 100%; }
  .tool { grid-template-columns: minmax(0, 1fr); }
  .form-panel { position: static; max-height: none; }
  .tool-tabs { display: flex; gap: 8px; margin: 14px 0 0; }
  .tool-tabs button { flex: 1; font: inherit; font-weight: 700; min-height: 46px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 8px; cursor: pointer; }
  .tool-tabs button[aria-pressed=true] { background: var(--text-strong); color: var(--bg); border-color: var(--text-strong); }
  .tool[data-view=form] .preview-panel { display: none; }
  .tool[data-view=preview] .form-panel { display: none; }
  .paper { padding: 26px 20px 30px; font-size: 13px; }
  .paper .doc-title { font-size: 21px; }
  .header-note { display: none; }
}

/* ---------- 방문 분석 동의 배너 (track.js, 추적 도구가 설정된 빌드에서만 생성) ---------- */
.consent { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50; max-width: 760px; margin: 0 auto; padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; background: var(--panel-2); border: 1px solid var(--muted); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.consent p { margin: 0; flex: 1 1 320px; font-size: .88rem; line-height: 1.6; }
.consent a { color: var(--text-strong); }
.consent .acts { display: flex; gap: 8px; margin-left: auto; }
.consent button, .consent-open { min-height: 44px; padding: 0 20px; border-radius: 8px; font: inherit; font-weight: 700; cursor: pointer; border: 1px solid var(--muted); background: transparent; color: var(--text-strong); }
.consent .consent-accept { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.consent-open { margin-left: 8px; padding: 0 14px; font-size: .85rem; }
body.has-consent { padding-bottom: 140px; }
@media (max-width: 560px) { body.has-consent { padding-bottom: 220px; } .consent .acts { width: 100%; } .consent .acts button { flex: 1; } }

/* ---------- 인쇄 ---------- */
@page { size: A4; margin: 16mm; }
@media print {
  body { background: #fff; display: block; }
  .no-print, .site-header, .site-footer, .ad-slot, .back, h1, .lead, .pill, .tool-tabs, .form-panel, .info-sec, .disclaimer, .related, noscript, .sub-mono, .consent { display: none !important; }
  .frame { display: block; padding: 0; max-width: none; }
  .tool { display: block; margin: 0; }
  .tool[data-view] .preview-panel { display: block !important; }
  .panel, .paper-wrap { background: none; border: 0; padding: 0; }
  .paper { box-shadow: none; padding: 0; max-width: none; min-height: 0; font-size: 12pt; }
}
