*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --surface-2: #f4f6f9;
  --border:    #e2e5eb;
  --text:      #1a1b2e;
  --muted:     #6b7280;
  --accent:    #2f6fed;
  --accent-2:  #5865f2;
  --radius:    12px;
  --maxw:      1200px;
  --sidebar-w: 280px;
}

html { color-scheme: light; }

body {
  font-family: 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ── 헤더 ── */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: var(--maxw); margin: 0 auto; padding: 16px 20px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.site-logo { font-size: 1.2rem; font-weight: 800; color: var(--accent); }
.site-nav { display: flex; gap: 16px; flex-wrap: wrap; flex: 1; }
.site-nav a {
  font-size: 0.9rem; font-weight: 600; color: var(--muted);
  padding: 6px 4px; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.site-nav a:hover, .site-nav a.active { color: var(--text); border-color: var(--accent); }

.search-form { display: flex; gap: 6px; }
.search-form input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; color: var(--text); font-size: 0.85rem; flex: 1; min-width: 0;
}
.search-form input:focus { outline: none; border-color: var(--accent); }
.search-form button {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); padding: 7px 12px; cursor: pointer; font-size: 0.85rem;
  flex-shrink: 0; white-space: nowrap;
}
.search-form button:hover { color: var(--accent); border-color: var(--accent); }

/* ── 레이아웃(본문 + 사이드바) ── */
main.container { padding-top: 32px; padding-bottom: 60px; min-height: 60vh; }
.layout { display: flex; align-items: flex-start; gap: 32px; }
.layout .content { flex: 1; min-width: 0; }
.layout .sidebar { width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column; gap: 18px; }

.page-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 20px; }
.page-title .muted { color: var(--muted); font-weight: 500; font-size: 0.95rem; margin-left: 8px; }

/* ── 사이드바 위젯 ── */
.widget { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.widget h4 { font-size: 0.78rem; font-weight: 800; margin-bottom: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.widget-search { background: none; border: none; padding: 6px 0; }
.widget-search .search-form input,
.widget-search .search-form button { background: var(--surface); }

.widget-visitor .rows { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; }
.widget-visitor .row { display: flex; justify-content: space-between; }
.widget-visitor .num { font-weight: 800; color: var(--accent); }
.widget-recent { display: flex; flex-direction: column; gap: 9px; }
.widget-recent a { font-size: 0.83rem; color: var(--text); line-height: 1.4; display: block; }
.widget-recent a:hover { color: var(--accent); }
.widget-recent .date { font-size: 0.72rem; color: var(--muted); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-cloud a { font-size: 0.76rem; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.tag-cloud a:hover { color: var(--accent); border-color: var(--accent); }
.widget-links { display: flex; flex-direction: column; gap: 8px; }
.widget-links a { font-size: 0.83rem; color: var(--muted); }
.widget-links a:hover { color: var(--accent); }
.widget-empty { font-size: 0.8rem; color: var(--muted); }

/* ── 글 카드 목록 ── */
.post-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.post-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: transform .15s, border-color .15s, box-shadow .15s;
}
.post-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 8px 20px rgba(47,111,237,0.08); }
.post-card .thumb {
  aspect-ratio: 16/10; background: var(--surface-2) center/cover no-repeat; flex-shrink: 0;
}
.post-card .thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.6rem; }
.post-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post-card .cat-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700; color: var(--accent);
  background: rgba(47,111,237,0.10); border-radius: 6px; padding: 2px 8px; width: fit-content;
}
.post-card h3 { font-size: 1rem; font-weight: 700; line-height: 1.4; }
.post-card .excerpt { font-size: 0.85rem; color: var(--muted); flex: 1; }
.post-card .meta { font-size: 0.75rem; color: var(--muted); display: flex; gap: 10px; }

.empty-state { color: var(--muted); text-align: center; padding: 60px 0; }

/* ── 페이지네이션 ── */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 36px; flex-wrap: wrap; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; border-radius: 8px; font-size: 0.85rem;
  border: 1px solid var(--border); color: var(--muted); background: var(--surface);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); color: #ffffff; border-color: var(--accent); font-weight: 700; }

/* ── 단일 글 ── */
.post-header { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.post-header h1 { font-size: 1.6rem; font-weight: 800; margin: 10px 0 12px; line-height: 1.4; }
.post-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 0.85rem; }

.post-content { font-size: 1rem; }
.post-content img, .post-content figure { max-width: 100%; height: auto; border-radius: 8px; margin: 12px 0; }
.post-content figure { margin: 16px 0; }
.post-content iframe { max-width: 100%; border-radius: 8px; }
.post-content a { color: var(--accent); text-decoration: underline; }
.post-content p { margin: 10px 0; }
.post-content blockquote { border-left: 3px solid var(--accent); padding-left: 14px; color: var(--muted); margin: 12px 0; }
.post-content pre { background: var(--surface-2); padding: 12px; border-radius: 8px; overflow-x: auto; }

.post-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 24px; }
.post-tags a {
  font-size: 0.8rem; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 12px; color: var(--muted);
}
.post-tags a:hover { color: var(--accent); border-color: var(--accent); }

/* ── 좋아요 ── */
.like-section { display: flex; justify-content: center; margin-top: 28px; }
.like-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-size: 0.9rem; font-weight: 700; color: var(--muted); transition: all .15s;
}
.like-btn:hover { border-color: #f87171; color: #ef4444; }
.like-btn.is-liked { color: #ef4444; border-color: #f87171; background: rgba(239,68,68,.08); }
.like-btn .icon { font-size: 1.05rem; }

/* ── 관련 글 ── */
.related-posts { margin-top: 40px; }
.related-posts h3 { font-size: 1.05rem; font-weight: 800; margin-bottom: 16px; }

/* ── 댓글/구분선 ── */
.comments-section, .section-divider { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.comments-section h3 { font-size: 1.05rem; font-weight: 800; margin-bottom: 16px; }

.post-nav-links { display: flex; justify-content: space-between; gap: 16px; margin-top: 40px; }
.post-nav-links a { flex: 1; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.85rem; color: var(--muted); }
.post-nav-links a:hover { border-color: var(--accent); }
.post-nav-links .label { font-size: 0.72rem; color: var(--accent); display: block; margin-bottom: 4px; }

/* ── 카테고리 pill(모바일 등에서 사용) ── */
.category-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.category-pills a {
  font-size: 0.82rem; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
}
.category-pills a:hover, .category-pills a.active { color: #fff; background: var(--accent); border-color: var(--accent); }

/* 글 상세 맨 위(상단 메뉴 바로 아래)에 올 때 — 위쪽 간격은 좁게, 아래(아티클) 간격은 넓게 */
.category-pills--top { margin-top: -16px; margin-bottom: 28px; }

/* ── 공용 폼/버튼/알림(공개+관리자 화면 공용) ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.form-group input[type=text],
.form-group input[type=password],
.form-group input[type=search],
.form-group select,
.form-group textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--text); font-size: 0.9rem; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 0.85rem; font-weight: 700;
  cursor: pointer; text-align: center; white-space: nowrap; flex-shrink: 0;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.btn--primary:hover { color: #ffffff; opacity: .9; }
.btn--danger { color: #f87171; }
.btn--danger:hover { border-color: #f87171; }
.btn--block { width: 100%; }

.flash { padding: 10px 14px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 16px; }
.flash--error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #f87171; }
.flash--success { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3); color: #4ade80; }

/* 허니팟(스팸봇 함정) 필드 — 일반 사용자에게는 보이지 않음 */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ── 푸터 ── */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: 0.8rem; text-align: center; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .layout .sidebar { width: 100%; order: 2; }
  .layout .content { order: 1; }
}

@media (max-width: 640px) {
  .site-header .inner { gap: 12px; }
}
