/* ===== 편집형(신문·공공기관 톤) 디자인: 각진 모서리 + 얇은 선 + 세리프 제목 ===== */
:root {
  --bg: #ffffff;
  --paper: #f6f5f2;
  --surface: #ffffff;
  --text: #1b1d21;
  --muted: #5f646c;
  --line: #dcd9d3;
  --line-strong: #1b1d21;
  --brand: #1f4e79;
  --brand-2: #2a5f91;
  --accent: #b5832f;
  --tip: #f3f6f9;
  --radius: 2px;
  --radius-btn: 3px;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "AppleMyungjo", serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  line-height: 1.8;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-2); text-underline-offset: 3px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* ===== header ===== */
.site-header { background: var(--surface); border-top: 4px solid var(--brand); border-bottom: 1px solid var(--line-strong); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.logo { font-family: var(--serif); font-weight: 800; font-size: 1.25rem; color: var(--text); text-decoration: none; white-space: nowrap; letter-spacing: -.01em; }
.site-header nav { display: flex; gap: 22px; overflow-x: auto; }
.site-header nav a { color: var(--text); text-decoration: none; font-size: .93rem; font-weight: 500; white-space: nowrap; padding: 4px 0; border-bottom: 2px solid transparent; }
.site-header nav a:hover { border-bottom-color: var(--brand); }

/* ===== hero ===== */
.hero { padding: 48px 0 36px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.hero h1 { font-family: var(--serif); font-size: clamp(1.8rem, 4.5vw, 2.5rem); line-height: 1.35; margin: 0 0 12px; font-weight: 700; }
.hero p { color: var(--muted); margin: 0 0 14px; font-size: 1.05rem; max-width: 640px; }

/* ===== sections & cards ===== */
.cat-section { margin: 36px 0 44px; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; padding-bottom: 10px; border-bottom: 2px solid var(--line-strong); }
.sec-head h1, .sec-head h2 { margin: 0; font-family: var(--serif); font-size: 1.35rem; }
.sec-head a { font-size: .88rem; color: var(--muted); text-decoration: none; }
.sec-head a:hover { color: var(--brand); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 28px; }
.card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 0 20px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--text);
}
.card:hover h3 { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.card h3 { margin: 2px 0 0; font-size: 1.07rem; line-height: 1.5; font-weight: 700; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.65; flex: 1; }
.card time, .post-head time { color: var(--muted); font-size: .8rem; }
.badge { align-self: flex-start; font-size: .74rem; font-weight: 700; padding: 0; border-radius: 0; text-decoration: none; letter-spacing: .02em; background: none !important; }
.badge.c0 { color: #1f4e79; } .badge.c1 { color: #136f63; } .badge.c2 { color: #8a5a14; }
.badge.c3 { color: #5b3aa8; } .badge.c4 { color: #a3324c; } .badge.c5 { color: #2456a6; }

/* ===== post ===== */
.crumbs { max-width: 760px; margin: 22px auto 0; font-size: .82rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); }
.post { max-width: 760px; margin: 10px auto 28px; padding: 0; background: none; border: 0; }
.post-head { padding: 14px 0 22px; border-bottom: 1px solid var(--line-strong); }
.post-head h1 { font-family: var(--serif); font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.4; margin: 10px 0 12px; font-weight: 700; letter-spacing: -.01em; }
.post-head .lead { color: var(--muted); margin: 0 0 12px; font-size: 1.05rem; }
.byline { color: var(--muted); font-size: .84rem; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.byline a { color: var(--muted); }
.trust-line { margin: 10px 0 0; font-size: .82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.trust-line span::before { content: "■ "; color: var(--brand); font-size: .6rem; vertical-align: 2px; }

.summary { background: var(--paper); border: 0; border-left: 4px solid var(--brand); border-radius: 0; padding: 18px 22px; margin: 26px 0 0; }
.summary-title { font-weight: 800; color: var(--brand); margin: 0 0 6px; font-size: .9rem; letter-spacing: .02em; }
.summary p:last-child { margin: 0; }

.toc { border: 1px solid var(--line); border-radius: 0; padding: 16px 20px; margin: 26px 0; background: var(--surface); }
.toc summary { font-weight: 700; font-size: .9rem; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: "펼치기 ▾"; margin-left: auto; font-weight: 500; font-size: .8rem; color: var(--muted); }
.toc[open] summary::after { content: "접기 ▴"; }
.toc[open] summary { margin-bottom: 6px; }
.toc ol { margin: 0; padding-left: 20px; font-size: .95rem; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--brand); text-decoration: underline; }

.post-body h2 { font-family: var(--serif); font-size: 1.38rem; margin: 46px 0 14px; padding-top: 0; scroll-margin-top: 80px; border-top: 0; font-weight: 700; }
.post-body h2::before { content: ""; display: block; width: 32px; height: 3px; background: var(--brand); margin-bottom: 14px; }
.post-body h3 { font-size: 1.1rem; margin: 30px 0 8px; }
.post-body p, .post-body li { font-size: 1.04rem; }
.post-body li { margin: 5px 0; }
.tip { background: var(--tip); border-left: 3px solid var(--brand-2); border-radius: 0; padding: 14px 18px; margin: 22px 0; font-size: .97rem; }
.table-wrap { overflow-x: auto; margin: 22px 0; }
table { border-collapse: collapse; width: 100%; font-size: .94rem; border-top: 2px solid var(--line-strong); }
th, td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
th { background: var(--paper); white-space: nowrap; font-weight: 700; }

/* FAQ: 상자 대신 구분선 */
.faq { display: block; margin: 16px 0; border-top: 1px solid var(--line-strong); }
.faq-item { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 16px 0; }
.faq-item .q { margin: 0 0 6px; font-size: 1.02rem; color: var(--text); font-weight: 700; }
.faq-item .a { margin: 0; color: #33373d; }

/* 참고 자료(출처) */
.sources { background: var(--paper); border-top: 2px solid var(--line-strong); padding: 16px 20px 14px; margin: 18px 0 8px; }
.sources ol { margin: 0; padding-left: 22px; font-size: .93rem; }
.sources li { margin: 4px 0; word-break: break-all; }
.sources .sources-note { margin: 10px 0 0; font-size: .8rem; color: var(--muted); }

/* 신뢰 안내 박스 */
.trust-box { border: 1px solid var(--line); border-radius: 0; padding: 16px 20px; margin: 28px 0 0; font-size: .88rem; color: var(--muted); }
.trust-box strong { color: var(--text); }
.trust-box p { margin: 4px 0; }

/* 코드 */
.post-body code { background: var(--paper); border: 1px solid var(--line); border-radius: 2px; padding: 1px 6px; font-size: .9em; }
.post-body pre { background: #1e2230; color: #e8eaf0; border-radius: 2px; padding: 16px 18px; overflow-x: auto; line-height: 1.6; }
.post-body pre code { background: none; border: 0; padding: 0; color: inherit; font-size: .9rem; white-space: pre-wrap; }

/* ===== CTA ===== */
.cta { background: var(--brand); color: #fff; border-radius: var(--radius); padding: 26px 26px; margin: 38px 0; }
.cta p { margin: 0 0 14px; opacity: .93; }
.cta .cta-title { font-size: 1.15rem; font-weight: 800; opacity: 1; margin-bottom: 6px; }
.cta-btn { display: inline-block; background: var(--accent); color: #fff; font-weight: 700; padding: 12px 22px; border-radius: var(--radius-btn); text-decoration: none; }
.cta-btn:hover { filter: brightness(1.06); }
.hero .cta-btn { background: var(--brand); }
.cta-inline { font-weight: 600; }
.float-cta {
  position: fixed; right: 16px; bottom: 16px; z-index: 20;
  background: var(--brand); color: #fff; font-weight: 700; text-decoration: none;
  padding: 12px 18px; border-radius: var(--radius-btn); box-shadow: 0 4px 14px rgba(0,0,0,.18); font-size: .93rem;
  border-left: 4px solid var(--accent);
}

/* 지연 로딩 배너 자리 (레이아웃 흔들림 방지) */
.cta-slot { display: block; min-height: 170px; margin: 38px 0; border-radius: var(--radius); background: var(--paper); }
.cta-slot.cta { background: var(--brand); }
.promo-slot { min-height: 1px; }
.hero-slot { display: inline-block; min-height: 46px; }

/* 하단 프로모션 */
.promo { background: var(--paper); border-top: 1px solid var(--line-strong); margin-top: 44px; padding: 38px 0; }
.promo-inner { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; align-items: center; }
.promo h2 { font-family: var(--serif); margin: 6px 0 8px; font-size: clamp(1.3rem, 3vw, 1.65rem); line-height: 1.4; }
.promo .eyebrow { display: inline-block; font-size: .78rem; font-weight: 700; color: var(--accent); letter-spacing: .04em; }
.promo ul { margin: 12px 0 18px; padding-left: 20px; }
.promo-visual { background: var(--brand); border-radius: var(--radius); min-height: 200px; display: grid; place-items: center; color: #fff; padding: 24px; text-align: center; }
.promo-visual svg { width: 160px; height: auto; }
@media (max-width: 720px) { .promo-inner { grid-template-columns: 1fr; } .promo-visual { min-height: 150px; } }

/* 이전글 / 다음글 */
.pager { max-width: 760px; margin: 0 auto 36px; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.pager-link { display: flex; flex-direction: column; gap: 4px; padding: 16px 4px; text-decoration: none; color: var(--text); }
.pager-link + .pager-link, .pager > span + .pager-link { border-left: 1px solid var(--line); padding-left: 18px; }
.pager-link:hover .pager-title { color: var(--brand); text-decoration: underline; }
.pager-link.next { text-align: right; }
.pager-label { font-size: .78rem; color: var(--muted); letter-spacing: .02em; }
.pager-title { font-weight: 600; line-height: 1.5; }
@media (max-width: 600px) { .pager { grid-template-columns: 1fr; } .pager-link.next { text-align: left; } .pager-link + .pager-link { border-left: 0; border-top: 1px solid var(--line); padding-left: 4px; } }

.related { max-width: 760px; margin: 0 auto 48px; }
.related h2 { font-family: var(--serif); font-size: 1.2rem; padding-bottom: 10px; border-bottom: 2px solid var(--line-strong); margin-bottom: 0; }
.related .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* ===== footer ===== */
.site-footer { border-top: 1px solid var(--line-strong); background: var(--paper); padding: 30px 0 84px; margin-top: 44px; font-size: .88rem; }
.site-footer p { margin: 6px 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.footer-links a { color: var(--text); }

/* 스크롤 모달 */
.cta-modal { position: fixed; inset: 0; z-index: 100; background: rgba(15, 20, 30, .55); display: grid; place-items: center; padding: 16px; animation: ctaFade .2s ease-out; }
.cta-modal-box { position: relative; width: min(420px, 100%); background: var(--surface); border-radius: 4px; border-top: 4px solid var(--brand); padding: 30px 24px 20px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.cta-modal-title { font-family: var(--serif); font-size: 1.25rem; font-weight: 800; margin: 0 0 8px; color: var(--text); }
.cta-modal-box p { margin: 0 0 18px; color: var(--text); }
.cta-modal-box .cta-btn { display: block; }
.cta-modal-x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 6px; }
.cta-modal-skip { margin-top: 12px; border: 0; background: none; color: var(--muted); font-size: .85rem; text-decoration: underline; cursor: pointer; }
@keyframes ctaFade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .cta-modal { animation: none; } }

@media (max-width: 600px) {
  .site-header .wrap { height: auto; padding-top: 10px; padding-bottom: 10px; flex-direction: column; align-items: flex-start; gap: 4px; }
  .site-header nav { gap: 16px; width: 100%; }
  .hero { padding: 32px 0 24px; }
}
.hero .trust-line { margin: 0 0 22px; }

/* 제목 줄바꿈 균형 (한 단어만 다음 줄로 넘어가는 것 방지) */
h1, h2, h3, .card h3, .pager-title { text-wrap: balance; }
.post-body p, .summary p { text-wrap: pretty; }

/* ===== 모바일 최적화 ===== */
html { -webkit-text-size-adjust: 100%; }
@media (min-width: 1000px) { .toc summary { pointer-events: none; } .toc summary::after { display: none; } }
@media (max-width: 600px) {
  /* 메뉴: 가로 스크롤 + 오른쪽 흐림으로 더 있다는 표시 */
  .site-header nav { margin: 0 -16px; padding: 0 16px; width: calc(100% + 32px); scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .site-header nav::-webkit-scrollbar { display: none; }
  .site-header nav a { padding: 8px 0; }
  .site-header nav a:last-child { margin-right: 24px; }
  /* 본문 가독성 */
  .post-head h1 { font-size: 1.5rem; }
  .post-body h2 { font-size: 1.28rem; }
  .post-body li { margin: 6px 0; }
  .toc { padding: 14px 16px; }
  .crumbs { font-size: .8rem; }
  .cta-slot { margin: 30px 0; }
  .cta-btn { display: block; text-align: center; }
  /* 하단 고정 버튼: 본문 가리지 않게 얇은 전체폭 바 */
  .float-cta { left: 0; right: 0; bottom: 0; border-radius: 0; border-left: 0; text-align: center;
    padding: 13px 16px calc(13px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 10px rgba(0,0,0,.12); }
  body:has(.float-cta) { padding-bottom: 52px; }
  .site-footer { padding-bottom: 40px; }
  .cta-modal-box { padding: 28px 18px 16px; }
  .related .grid { grid-template-columns: 1fr; }
}

/* 복사 상자 (``` 블록) */
.copybox { position: relative; margin: 22px 0; }
.copybox pre { margin: 0; padding-right: 76px; }
.copy-btn { position: absolute; top: 10px; right: 10px; font: inherit; font-size: .8rem; font-weight: 700; padding: 5px 12px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12); color: #fff; border-radius: 4px; cursor: pointer; }
.copy-btn:hover { background: rgba(255,255,255,.22); }
.copy-btn.done { background: #16a34a; border-color: #16a34a; }

/* 함께 보면 좋은 사이트 */
.xl-group { margin: 34px 0 0; }
.xl-cats { color: var(--muted); font-size: .85rem; margin: -4px 0 10px; }
.xl-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.xl-item { border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; background: var(--surface, #fff); }
.xl-name { font-weight: 800; text-decoration: none; color: var(--brand); font-size: 1.02rem; }
.xl-name:hover { text-decoration: underline; }
.xl-ext { font-size: .8em; margin-left: 4px; }
.xl-host { display: block; font-size: .78rem; color: var(--muted); margin-top: 2px; word-break: break-all; }
.xl-desc { margin: 8px 0 0; font-size: .92rem; line-height: 1.6; }
.xl-note { margin-top: 30px; font-size: .85rem; color: var(--muted); }

/* 사진 출처는 사진을 눌렀을 때 모달에서만 */
figure:has(> img) > figcaption, figure:has(> picture) > figcaption { display: none; }
figure > img { cursor: zoom-in; }
.lb { position: fixed; inset: 0; z-index: 200; background: rgba(10, 14, 20, .82); display: grid; place-items: center; padding: 16px; }
.lb-box { position: relative; max-width: min(1100px, 100%); }
.lb-box img { display: block; max-width: 100%; max-height: 78vh; width: auto; height: auto; margin: 0 auto; border-radius: 2px; }
.lb-cap { color: #e8eaf0; font-size: .85rem; text-align: center; margin-top: 10px; line-height: 1.6; }
.lb-cap a { color: #fff; text-decoration: underline; }
.lb-x { position: absolute; top: -40px; right: 0; background: none; border: 0; color: #fff; font-size: 2rem; line-height: 1; cursor: pointer; padding: 4px 8px; }

/* 글 대표 사진: 작게 (누르면 모달에서 크게) */
.post-figure { max-width: 640px; margin-left: 0; margin-right: auto; }
.post-figure img { width: 100%; height: auto; max-height: 300px; object-fit: cover; }
@media (max-width: 600px) { .post-figure img { max-height: 200px; } }

/* 본문 그림 (역사 시리즈 등) */
.inline-figure { margin: 26px 0; max-width: 560px; }
.inline-figure img { display: block; width: 100%; height: auto; max-height: 340px; object-fit: contain; background: #f4f6f8; border-radius: 6px; border: 1px solid var(--line); }
.inline-cap { display: block; margin-top: 8px; font-size: .85rem; color: var(--muted); line-height: 1.5; }

/* WebP: <picture> 로 감싼 이미지도 기존 배치 그대로 */
picture { display: contents; }
figure > picture > img { cursor: zoom-in; }
