/* ═══════════════════════════════════════════════════════════════
   ESH-MASTER.KR | 티스토리 북클럽 스킨 CSS v7
   썸네일 16:9 · 관련글 이미지 추가 · CDN C640x360 기준
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700;900&family=Rajdhani:wght@600;700&display=swap');

:root {
  --navy:        #0A2540;
  --navy-mid:    #1E3A5F;
  --teal:        #14B8A6;
  --teal-light:  #E6FAF8;
  --teal-border: #B2EDE8;
  --border:      #E2E8F0;
  --text-1:      #0F172A;
  --text-2:      #475569;
  --text-3:      #94A3B8;
  --bg:          #F8FAFC;
  --bg-card:     #FFFFFF;
  --bg-subtle:   #F1F5F9;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.13);
  --radius:      12px;
  --font:        'Noto Sans KR', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text-1); font-size: 16px; line-height: 1.7; }
a { color: var(--teal); text-decoration: none; transition: color .2s; }
a:hover { color: var(--navy); }
img { max-width: 100%; height: auto; display: block; }

/* ════════════════════════════════════════════
   헤더
════════════════════════════════════════════ */
#header {
  background: var(--navy);
  border-bottom: 3px solid var(--teal);
  position: sticky; top: 0; z-index: 500;
}
#header .inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1240px; margin: 0 auto;
  padding: 0 40px; height: 64px;
}
#header h1 a {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none;
}
#header h1 a::before { display: none !important; }

/* EM 배지 */
.brand-badge {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px;
  background: #0D1F35;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  flex-shrink: 0;
}
.badge-text {
  position: relative;
  display: inline-block;
  line-height: 1;
}
.badge-em {
  font-family: 'Rajdhani', sans-serif;
  font-size: 18px; font-weight: 900;
  color: #fff; letter-spacing: .06em; display: block;
}
.badge-dot {
  position: absolute;
  bottom: 0; right: -5px;
  width: 5px; height: 5px;
  background: var(--teal);
  border-radius: 50%;
}

/* 브랜드 텍스트 */
.brand-wrap { display: flex; flex-direction: column; gap: 3px; }
.brand-main {
  font-family: 'Rajdhani', sans-serif;
  font-size: 20px; font-weight: 700;
  color: #fff; letter-spacing: .06em; line-height: 1;
}
.brand-sub {
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px; font-weight: 600;
  color: var(--teal); letter-spacing: .16em; line-height: 1;
}

/* ════════════════════════════════════════════
   헤더 우측 (GNB + 검색창)
════════════════════════════════════════════ */
.esh-header-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

#gnb { display: flex; align-items: center; }
#gnb ul { display: flex; gap: 2px; list-style: none; padding: 0; margin: 0; }
#gnb ul li a {
  color: rgba(255,255,255,.75); font-size: 14px; font-weight: 500;
  padding: 7px 14px; border-radius: 7px;
  display: block; transition: all .18s; white-space: nowrap;
}
#gnb ul li a:hover { background: rgba(20,184,166,.18); color: var(--teal); }

.esh-search {
  position: relative;
  display: flex;
  align-items: center;
}

.esh-search input {
  display: block !important;
  width: 160px !important;
  height: 36px !important;
  padding: 0 35px 0 16px !important;
  border: 1px solid rgba(148, 163, 184, 0.4) !important;
  border-radius: 18px !important;
  background: rgba(148, 163, 184, 0.2) !important;
  color: #fff !important;
  font-size: 14px !important;
  font-family: var(--font) !important;
  outline: none !important;
  transition: all 0.3s ease !important;
  box-sizing: border-box !important;
  margin: 0 !important;
}

.esh-search input::placeholder {
  color: rgba(255, 255, 255, 0.5) !important;
}

.esh-search input:focus {
  width: 200px !important;
  border-color: var(--teal) !important;
  background: rgba(148, 163, 184, 0.3) !important;
}

.esh-search button {
  position: absolute !important;
  right: 12px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: none !important;
  border: none !important;
  color: rgba(255, 255, 255, 0.6) !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  transition: color 0.2s !important;
  z-index: 10 !important;
}

.esh-search button:hover {
  color: var(--teal) !important;
}

/* ════════════════════════════════════════════
   레이아웃
════════════════════════════════════════════ */
#container { padding: 32px 0; }
.content-wrap {
  max-width: 1240px; margin: 0 auto; padding: 0 40px;
  display: flex; gap: 36px; align-items: flex-start;
}
#content { flex: 1; min-width: 0; }
#aside { width: 260px; flex-shrink: 0; }

/* ════════════════════════════════════════════
   글 목록 헤더
════════════════════════════════════════════ */
.post-header { margin-bottom: 20px; }
.post-header h1 {
  font-size: 22px; font-weight: 900; color: var(--navy);
  display: flex; align-items: baseline; gap: 8px;
}
.post-header h1 em { font-size: 16px; font-weight: 700; color: var(--teal); font-style: normal; }

/* ════════════════════════════════════════════
   글 목록 카드 (3열 고정)
════════════════════════════════════════════ */
#tt-body-index #content .inner,
#tt-body-category #content .inner,
#tt-body-tag #content .inner,
#tt-body-search #content .inner {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 20px !important;
}
#tt-body-page #content .inner {
  display: block !important;
}

.post-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
.post-item:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--teal-border);
}
.post-item > a { display: block; color: var(--text-1); }

/* ────────────────────────────────────────
   ★ 메인 썸네일 — 16:9 고정
──────────────────────────────────────── */
.post-item .thum {
  display: block !important;
  width: 100% !important;
  aspect-ratio: 16 / 9 !important;
  overflow: hidden !important;
  background: var(--bg-subtle) !important;
  position: relative !important;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}
.post-item .thum img {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center center !important;
  transition: transform .4s ease !important;
}
.post-item:hover .thum img { transform: scale(1.06) !important; }

/* 썸네일 없을 때 기본 배경 */
.post-item .thum:empty::after,
.post-item .thum:not(:has(img))::after {
  content: 'ESH';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Rajdhani', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--teal);
  background: var(--navy);
  letter-spacing: .1em;
}

/* 텍스트 영역 */
.post-item .title {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  color: var(--text-1) !important;
  line-height: 1.5 !important;
  padding: 14px 16px 6px !important;
  word-break: keep-all !important;
}
.post-item:hover .title { color: var(--teal) !important; }

.post-item .excerpt {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  font-size: 13px !important;
  color: var(--text-2) !important;
  line-height: 1.6 !important;
  padding: 0 16px !important;
}
.post-item .meta { display: block !important; padding: 8px 16px 16px !important; }
.post-item .date { font-size: 12px !important; color: var(--text-3) !important; }

/* ════════════════════════════════════════════
   글 본문 커버
════════════════════════════════════════════ */
.post-cover {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%) !important;
  background-image: none !important;
  border-radius: var(--radius);
  margin-bottom: 24px;
  position: relative; overflow: hidden;
}
.post-cover::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px; background: linear-gradient(90deg, var(--teal), #1E6BD8);
}
.post-cover .inner {
  display: block !important;
  background: none !important;
  padding: 36px 40px !important;
  position: relative; z-index: 1;
}
.post-cover h1 {
  font-size: 24px; font-weight: 900; color: #fff !important;
  line-height: 1.4; margin-bottom: 10px;
}
.post-cover .meta { font-size: 13px; color: rgba(255,255,255,.6) !important; }
.post-cover .category {
  display: inline-block; font-size: 11px; font-weight: 700;
  color: var(--teal); background: rgba(20,184,166,.15);
  border: 1px solid rgba(20,184,166,.3);
  padding: 3px 10px; border-radius: 4px; margin-bottom: 10px;
}

/* ════════════════════════════════════════════
   글 본문
════════════════════════════════════════════ */
.entry-content {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 40px 48px; margin-bottom: 24px;
  font-size: 16px; color: var(--text-1); line-height: 1.9;
}
.entry-content p { margin-bottom: 18px; color: #374151; }
.entry-content h2 { font-size: 20px; font-weight: 700; color: var(--navy); margin: 36px 0 14px; padding-bottom: 8px; border-bottom: 2px solid var(--teal); }
.entry-content h3 { font-size: 17px; font-weight: 700; color: var(--teal); margin: 24px 0 10px; }
.entry-content ul, .entry-content ol { padding-left: 20px; margin-bottom: 18px; }
.entry-content li { margin-bottom: 8px; }
.entry-content blockquote { border-left: 4px solid var(--teal); padding: 14px 20px; background: var(--teal-light); border-radius: 0 10px 10px 0; margin: 20px 0; color: var(--navy-mid); font-weight: 500; }
.entry-content strong { color: var(--navy); font-weight: 700; }
.entry-content a { color: var(--teal); border-bottom: 1px solid var(--teal-border); }
.entry-content img { max-width: 100%; border-radius: 10px; margin: 24px auto; box-shadow: var(--shadow-md); }
.entry-content table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 14px; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-sm); }
.entry-content th { background: var(--navy); color: #fff; font-weight: 700; padding: 11px 16px; text-align: left; }
.entry-content td { padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.entry-content tr:last-child td { border-bottom: none; }
.entry-content tr:nth-child(even) td { background: var(--bg-subtle); }

/* ════════════════════════════════════════════
   태그
════════════════════════════════════════════ */
.tags {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px; margin-bottom: 20px;
}
.tags h2 { font-size: 12px; font-weight: 700; color: var(--navy); letter-spacing: .08em; margin-bottom: 12px; }
.tags a {
  display: inline-block; font-size: 12px; font-weight: 600;
  color: var(--text-2); background: var(--bg-subtle);
  border: 1px solid var(--border); padding: 4px 12px;
  border-radius: 20px; margin: 3px; transition: all .2s;
}
.tags a:hover { background: var(--teal-light); border-color: var(--teal-border); color: var(--teal); }

/* ════════════════════════════════════════════
   ★ 관련글
════════════════════════════════════════════ */
.related-articles {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.related-articles h2 {
  font-size: 14px; font-weight: 700;
  color: var(--navy); margin-bottom: 16px;
}
.related-articles ul {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  list-style: none;
}
.related-articles li a { display: block; }

/* 관련글 썸네일 이미지 — 16:9 고정 */
.related-articles li a img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center center;
  border-radius: 8px;
  margin-bottom: 8px;
  transition: transform .3s ease, opacity .2s;
  background: var(--bg-subtle);
}
.related-articles li:hover a img {
  transform: scale(1.03);
  opacity: .9;
}

.related-articles .title {
  font-size: 13px; font-weight: 600;
  color: var(--text-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
  word-break: keep-all;
}
.related-articles li:hover .title { color: var(--teal); }

/* ════════════════════════════════════════════
   페이지네이션
════════════════════════════════════════════ */
.pagination { display: flex; justify-content: center; gap: 5px; margin: 28px 0; }
.pagination a {
  display: inline-flex; width: 38px; height: 38px;
  align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--border);
  border-radius: 9px; font-size: 14px; font-weight: 500;
  color: var(--text-2); box-shadow: var(--shadow-sm); transition: all .18s;
}
.pagination a:hover { background: var(--teal-light); border-color: var(--teal-border); color: var(--teal); }
.pagination .on { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 700; }
.pagination .prev, .pagination .next { width: auto; padding: 0 14px; font-size: 12px; }
.pagination .disabled { opacity: .35; pointer-events: none; }

/* ════════════════════════════════════════════
   사이드바
════════════════════════════════════════════ */
#aside { display: flex; flex-direction: column; gap: 16px; }
.sidebar-1, .sidebar-2 { display: flex; flex-direction: column; gap: 16px; }

.category, .notice, .post-list, .recent-comment, .count, .sidebar-tags {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.category h2, .notice h2, .post-list h2,
.recent-comment h2, .count h2, .sidebar-tags h2 {
  font-size: 11px; font-weight: 700; color: var(--navy);
  letter-spacing: .1em; text-transform: uppercase;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 2px solid var(--teal);
}
.category ul, .notice ul, .recent-comment ul { list-style: none; }
.category li a, .notice li a, .recent-comment li a {
  font-size: 13px; color: var(--text-2);
  display: block; padding: 5px 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-bottom: 1px solid transparent; transition: all .18s;
}
.category li a:hover,
.notice li a:hover,
.recent-comment li a:hover { color: var(--teal); border-bottom-color: var(--teal-border); }
.category li.on > a { color: var(--teal); font-weight: 700; }

/* ────────────────────────────────────────
   ★ 사이드바 최근글 썸네일
──────────────────────────────────────── */
.post-list ul { list-style: none; }
.post-list li a {
  display: flex; gap: 10px; align-items: center;
  padding: 6px 0; font-size: 13px; color: var(--text-2);
}
.post-list li a:hover { color: var(--teal); }
.post-list li img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  object-position: center center;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--bg-subtle);
}
.post-list .title {
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1;
}
.post-list .date { font-size: 11px; color: var(--text-3); white-space: nowrap; }

.count .total { font-size: 24px; font-weight: 900; color: var(--navy); margin: 8px 0 4px; }
.count p { font-size: 13px; color: var(--text-2); }

/* ════════════════════════════════════════════
   댓글
════════════════════════════════════════════ */
.comments, .tt-comments-wrap {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 32px; margin-bottom: 20px;
}

/* ════════════════════════════════════════════
   푸터
════════════════════════════════════════════ */
#footer {
  background: var(--navy);
  border-top: 3px solid var(--teal);
  padding: 36px 40px; margin-top: 48px;
}
#footer .inner {
  max-width: 1240px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.footer-brand { font-family: 'Rajdhani', sans-serif; font-size: 20px; font-weight: 700; color: #fff; letter-spacing: .06em; }
#footer .meta { font-size: 12px; color: var(--teal); letter-spacing: .1em; }
#footer .copyright { font-size: 12px; color: rgba(255,255,255,.4); }
#footer .page-top {
  font-size: 12px; font-weight: 700; color: var(--teal);
  border: 1px solid var(--teal); padding: 4px 16px;
  border-radius: 20px; transition: all .2s; margin-top: 4px;
}
#footer .page-top:hover { background: var(--teal); color: var(--navy); }

/* ════════════════════════════════════════════
   페이지(단일글) 커버 — 흰 배경
════════════════════════════════════════════ */
#tt-body-page .post-cover h1,
#tt-body-page .post-cover h1 a { color: var(--navy) !important; }
#tt-body-page .post-cover .meta,
#tt-body-page .post-cover .meta span,
#tt-body-page .post-cover .author,
#tt-body-page .post-cover .date { color: var(--text-2) !important; }
#tt-body-page .post-cover {
  background: #fff !important;
  border: 1px solid var(--border) !important;
  padding: 32px 40px !important;
  background-image: none !important;
}

/* ════════════════════════════════════════════
   반응형
════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .content-wrap { padding: 0 24px; gap: 24px; }
  #aside { width: 220px; }
  #header .inner { padding: 0 24px; }
  #tt-body-index #content .inner,
  #tt-body-category #content .inner,
  #tt-body-tag #content .inner,
  #tt-body-search #content .inner {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .related-articles ul { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .content-wrap { flex-direction: column; padding: 0 16px; }
  #aside { width: 100%; }
  #header .inner { padding: 0 16px; }
  #gnb { display: none; }
  .esh-header-right { gap: 12px; }
  .esh-search input { width: 130px !important; }
  .esh-search input:focus { width: 150px !important; }
  .entry-content { padding: 24px 20px; }
  #content .inner { grid-template-columns: 1fr !important; }
  .post-cover .inner { padding: 24px !important; }
  .post-cover h1 { font-size: 20px; }
  /* 모바일: 관련글 1열 */
  .related-articles ul { grid-template-columns: 1fr; }
}