/* =========================================================
   return new Story(); — Tistory Skin
   OpenAI Developer Blog 스타일 차용 / 백엔드 개발자용 미니멀 스킨
   ========================================================= */

/* -----------------------------------------
   Tokens
   ----------------------------------------- */
:root {
  /* Text */
  --text-primary: #0a0a0a;
  --text-secondary: #555555;
  --text-tertiary: #888888;
  --text-muted: #999999;

  /* Background */
  --bg-primary: #ffffff;
  --bg-secondary: #fafaf8;
  --bg-tertiary: #f4f4f0;

  /* Border */
  --border-light: #e8e8e3;
  --border-medium: #d4d4cf;

  /* Syntax */
  --syntax-keyword: #af52de;
  --syntax-class:   #007aff;

  /* Fonts — Pretendard Variable (jsdelivr) + JetBrains Mono (Google Fonts) */
  --font-sans: "Pretendard Variable", "Pretendard",
               -apple-system, BlinkMacSystemFont,
               "Apple SD Gothic Neo", "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono",
               "D2Coding", Menlo, Consolas, monospace;

  /* Type scale */
  --fs-xs: 11px;
  --fs-sm: 13px;
  --fs-base: 16px;
  --fs-md: 18px;
  --fs-lg: 22px;
  --fs-xl: 28px;

  /* Layout */
  --sidebar-width: 220px;
  --container-max: 1280px;
  --article-max: 720px;
  --header-h: 56px;
  --gutter: 32px;
  --gutter-sm: 20px;
}

/* -----------------------------------------
   Reset & base
   ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: 400;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* sticky footer — 본문이 짧아도 footer 가 viewport 아래에 앉도록 */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.layout { flex: 1; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }
button { font: inherit; cursor: pointer; background: none; border: 0; padding: 0; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
input, textarea, select { font: inherit; color: inherit; }
ul, ol { padding: 0; margin: 0; list-style: none; }
h1, h2, h3, h4, h5, h6, p { margin: 0; }
hr { border: 0; border-top: 0.5px solid var(--border-light); margin: 32px 0; }

::selection { background: var(--bg-tertiary); }

/* -----------------------------------------
   Header
   ----------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 0.5px solid var(--border-light);
}
.header-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--gutter-sm);
  height: var(--header-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-code .kw  { color: var(--syntax-keyword); }
.brand-code .cls { color: var(--syntax-class); }

.nav-main {
  display: flex;
  align-items: center;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  justify-self: end;
}
/* [##_blog_menu_##] 자동 마크업 (ul/li 기반) reset 및 정렬 */
.nav-main ul,
.nav-main ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 22px;
}
.nav-main li { margin: 0; }
.nav-main a {
  transition: color .15s ease;
  text-decoration: none;
  color: var(--text-secondary);
}
.nav-main a:hover { color: var(--text-primary); }

/* 글 단위 admin 도구 — <s_ad_div> 그룹 (관리자에게만 자동 표시) */
.post-admin {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding: 8px 0;
  border-top: 0.5px dashed var(--border-light);
}
.post-admin-link {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.post-admin-link:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.post-admin-link.post-admin-danger { color: var(--syntax-keyword); }
.post-admin-link.post-admin-danger:hover { background: var(--syntax-keyword); color: #fff; }

.site-subtitle {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--gutter-sm) 14px;
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  letter-spacing: -0.01em;
}
.site-subtitle:empty { display: none; }

/* Hamburger */
.nav-toggle {
  display: none;
  width: 32px;
  height: 32px;
  position: relative;
  margin-left: -6px;
}
.nav-toggle span {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 1.5px;
  background: var(--text-primary);
  transition: transform .2s ease, opacity .2s ease, top .2s ease;
}
.nav-toggle span:nth-child(1) { top: 10px; }
.nav-toggle span:nth-child(2) { top: 15px; }
.nav-toggle span:nth-child(3) { top: 20px; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { top: 15px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { top: 15px; transform: rotate(-45deg); }

/* -----------------------------------------
   Layout
   ----------------------------------------- */
.layout {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 32px var(--gutter-sm) 64px;
  box-sizing: border-box;
  display: grid;
  /* minmax(0, 1fr) — main 셀이 콘텐츠 fit 으로 줄어들지 않고 항상 자유 공간 차지.
     덕분에 글 상세 (post-detail max-width 720) 페이지에서도 layout 이 viewport
     가득 채우고, 사이드바 자연 위치도 그대로 좌측 고정. */
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 48px;
}
body[data-sidebar="0"] .layout {
  grid-template-columns: 1fr;
  max-width: calc(var(--article-max) + var(--gutter-sm) * 2);
}
body[data-sidebar="0"] .sidebar { display: none; }

.main { min-width: 0; grid-column: 2; }
body[data-sidebar="0"] .main { grid-column: 1; }

/* -----------------------------------------
   Sidebar
   ----------------------------------------- */
/* 데스크톱(≥1024px): 사이드바 viewport 에 완전 고정.
   top/left 명시 X — fixed 의 hypothetical static position(=grid 첫 셀 자리) 사용.
   덕분에 layout padding/header 와 자동 정렬, 헤더 영역 침범 없음. */
.sidebar {
  position: fixed;
  width: var(--sidebar-width);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: var(--fs-sm);
  padding-right: 8px;
  scrollbar-width: thin;
  z-index: 5;
}
.sidebar-header { display: none; } /* 데스크톱에선 숨김 (모바일 드로어 전용) */
.sidebar-inner {
  /* sidebar 자체가 fixed — 별도 sticky 필요 없음 */
  padding-left: 12px !important;   /* 모바일 미디어쿼리의 padding shorthand 를 이기기 위해 !important */
}
.sb-block + .sb-block { margin-top: 20px; padding-top: 16px; border-top: 0.5px solid var(--border-light); }
.sb-label {
  font-size: var(--fs-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 10px;
  padding: 0 10px;
}

/* Sidebar generic list (recent etc) */
.sb-list li a {
  display: block;
  padding: 6px 10px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.sb-list li a:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* Sidebar — 카테고리 자동 출력 마크업 ([##_category_##])
   Tistory 설정에 따라 두 마크업이 모두 가능:
   (A) ul.tt_category 트리   — 권장. 표시 형태=일반 일 때
   (B) <table> 기반            — 옛/공지 형태. table.category_<id> + td.branch3 */

/* (A) ul 기반 — 깔끔한 트리 */
.sb-block .tt_category,
.sb-block .tt_category ul,
.sb-block .category_list,
.sb-block .sub_category_list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sb-block .tt_category li { margin: 0; }
.sb-block .tt_category .link_tit {
  font-weight: 500;
  color: var(--text-primary);
  font-size: var(--fs-sm);
}
.sb-block .tt_category .link_item {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}
.sb-block .tt_category .link_sub_item {
  font-size: 12px;
  color: var(--text-tertiary);
}
.sb-block .sub_category_list {
  margin: 2px 0 6px;
  padding-left: 12px;
  border-left: 0.5px solid var(--border-light);
  margin-left: 4px;
}

/* (B) <table> 기반 — 강제 평탄화 + 모든 sub 펼침 */
.sb-block table,
.sb-block tbody,
.sb-block tr,
.sb-block td {
  display: block !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent;
  width: auto;
  box-sizing: border-box;
}
.sb-block td.ib { display: none !important; }   /* tree image (펼침/접힘 아이콘) */
.sb-block table img { display: none !important; }
/* sub-tree 펼침: table.category_<id> 직후 wrapping div 가 inline display:none 으로 박혀
   접힘 처리되므로 강제로 펼침 */
.sb-block table div,
.sb-block table[class*="category_"] ~ div,
.sb-block td > div { display: block !important; }

.sb-block a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
  overflow: hidden;
}
.sb-block a > span,
.sb-block a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-block a:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.sb-block a.is-current,
.sb-block .current a {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 500;
}
.sb-block .c_cnt,
.sb-block .num {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-left: auto;
  flex-shrink: 0;
}

/* root 카테고리 — RECENT 항목과 동일 톤 (회색 + 13px) */
.sb-block td.branch3 {
  color: var(--text-secondary) !important;
  font-size: var(--fs-sm) !important;
  font-weight: 400 !important;
  padding: 3px 10px !important;
  line-height: 1.4 !important;
}

/* sub 카테고리 (table.category_<id> 안의 td.branch3): 들여쓰기 + 살짝 옅은 톤
   세로 마진 0 — Tistory 가 sub-item 마다 별도 <table> 을 뽑는 케이스에서
   border-left 가 끊어지지 않고 연속되게 함 */
.sb-block table[class*="category_"] {
  margin: 0 0 0 4px !important;
  padding-left: 10px !important;
  border-left: 0.5px solid var(--border-light) !important;
}
.sb-block table[class*="category_"] td.branch3 {
  font-size: 12px !important;
  color: var(--text-tertiary) !important;
}
.sb-block table[class*="category_"] table[class*="category_"] {
  margin-left: 6px !important;
}

/* Sidebar search */
.sb-search-form {
  display: flex;
  gap: 6px;
}
.sb-search-form input[type="text"],
.sb-search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  font-size: var(--fs-sm);
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-light);
  border-radius: 6px;
  outline: none;
  transition: border-color .15s ease;
  font-family: inherit;
}
.sb-search-form input:focus { border-color: var(--text-primary); }
.sb-search-form button {
  padding: 0 10px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  border: 0.5px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-secondary);
}
.sb-search-form button:hover { color: var(--text-primary); }

/* Drawer backdrop (mobile) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 60;
  display: none;
}

/* -----------------------------------------
   Notice (pinned posts)
   풀폭 가로 카드 — 일반 카드와 시각적으로 구분
   ----------------------------------------- */
.notice-card {
  grid-column: 1 / -1;
  border-bottom: 0.5px solid var(--border-light);
  padding-bottom: 28px;
  margin-bottom: 4px;
}
.notice-card-link {
  display: grid;
  grid-template-columns: minmax(0, 280px) 1fr;
  gap: 28px;
  align-items: stretch;
}
.notice-card-thumb {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-tertiary);
  border-radius: 8px;
}
.notice-card-thumb.is-empty { display: none; }
.notice-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s ease;
}
.notice-card:hover .notice-card-thumb img { transform: scale(1.02); }

.notice-card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}
.notice-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
}
.notice-card-title {
  font-size: var(--fs-lg);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text-primary);
}
.notice-card-summary {
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notice-card-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* -----------------------------------------
   Tag cloud (/tag 페이지 전용)
   ----------------------------------------- */
.tag-cloud-wrap { display: none; }
#tt-body-tag .tag-cloud-wrap { display: block; }
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 8px;
}
.tag-cloud-item {
  display: inline-block;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.tag-cloud-item:hover {
  background: var(--text-primary);
  color: var(--bg-primary);
}
/* 태그 빈도 (cloud1=많이쓰는 태그, cloud5=적게) — 글자 크기로 차별화 */
.tag-cloud-item.cloud1 { font-size: 18px; font-weight: 500; padding: 8px 14px; }
.tag-cloud-item.cloud2 { font-size: 16px; padding: 7px 13px; }
.tag-cloud-item.cloud3 { font-size: 14px; }
.tag-cloud-item.cloud4 { font-size: 13px; color: var(--text-tertiary); }
.tag-cloud-item.cloud5 { font-size: 12px; color: var(--text-tertiary); }

/* -----------------------------------------
   Notice wrapper (인덱스 PINNED)
   ----------------------------------------- */
.notice-wrap { margin-bottom: 32px; }

/* -----------------------------------------
   List page header (카테고리/태그/검색)
   ----------------------------------------- */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 0.5px solid var(--border-light);
}
.list-meta {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}
.list-meta .post-cat {
  font-weight: 500;
  color: var(--text-primary);
}
.list-header .paging-top { margin: 0; }
/* 인덱스에선 메타 의미 없음 — paging 만 우측 단독 표시 */
#tt-body-index .list-header {
  justify-content: flex-end;
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 16px;
}
#tt-body-index .list-meta { display: none; }

.empty-msg {
  grid-column: 1 / -1;
  padding: 120px 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
}

/* -----------------------------------------
   Post cards grid — 모든 글 목록 페이지에서 동일
   ----------------------------------------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px 24px;
}

.post-card { transition: transform .2s ease; }
.post-card-link { display: block; }
.post-card-thumb {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border: 0.5px solid var(--border-light);
  margin-bottom: 14px;
}
.post-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s ease;
}
.post-card:hover .post-card-thumb img { transform: scale(1.02); }

.post-card-body { padding: 0 2px; display: flex; flex-direction: column; gap: 6px; }
.post-card-title {
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.35;
  margin: 0;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.post-meta .dot { opacity: 0.6; }
.post-meta .post-cat { color: var(--text-secondary); }
.post-meta .post-cmt { color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.post-meta .is-zero { display: none; }

/* -----------------------------------------
   Permalink (post detail)
   ----------------------------------------- */
.post-detail {
  max-width: var(--article-max);
  margin: 0 auto;
}
.post-header { margin-bottom: 32px; }
.post-title {
  font-size: var(--fs-xl);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text-primary);
  margin-top: 8px;
}

.post-body {
  font-size: var(--fs-base);
  line-height: 1.75;
  color: var(--text-primary);
}
.post-body > * + * { margin-top: 1.1em; }
.post-body h2 {
  font-size: var(--fs-lg);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-top: 2.2em;
  margin-bottom: 0.6em;
}
.post-body h3 {
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
}
.post-body a {
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-medium);
  transition: border-color .15s ease;
}
.post-body a:hover { border-bottom-color: var(--text-primary); }
.post-body img {
  border-radius: 6px;
  margin: 1.4em auto;
}
.post-body blockquote {
  margin: 1.4em 0;
  padding: 12px 16px;
  border-left: 2px solid var(--text-primary);
  background: var(--bg-secondary);
  font-style: italic;
  color: var(--text-secondary);
  border-radius: 0 6px 6px 0;
}
.post-body code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-secondary);
  padding: 2px 5px;
  border-radius: 4px;
  border: 0.5px solid var(--border-light);
}
.post-body pre {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-light);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 1.4em 0;
}
.post-body pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
}
.post-body ul, .post-body ol { padding-left: 1.4em; }
.post-body ul { list-style: disc; }
.post-body ol { list-style: decimal; }
.post-body li + li { margin-top: 0.4em; }
.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  margin: 1.4em 0;
}
.post-body th, .post-body td {
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--border-light);
  text-align: left;
}
.post-body th { font-weight: 500; background: var(--bg-secondary); }
.post-body hr { margin: 2em 0; }

/* Tags — Tistory 가 a 사이에 ", " 텍스트 노드를 자동 삽입하므로
   JS 에서 텍스트 노드 제거 후 gap 으로 spacing 대체 */
.post-tags {
  max-width: var(--article-max);
  margin: 40px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.post-tags a {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border-radius: 4px;
  transition: background .15s ease, color .15s ease;
  text-decoration: none;
}
.post-tags a:hover { background: var(--border-light); color: var(--text-primary); }

/* Prev / Next nav */
.post-nav {
  max-width: var(--article-max);
  margin: 48px auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border-top: 0.5px solid var(--border-light);
  padding-top: 24px;
}
.post-nav-prev, .post-nav-next {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 0.5px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-primary);
  transition: background .15s ease, border-color .15s ease;
  min-width: 0;
}
.post-nav-prev { grid-column: 1; }   /* 이전 글 — 항상 좌측 */
.post-nav-next { grid-column: 2; text-align: right; }  /* 다음 글 — 항상 우측 */
.post-nav-prev:hover, .post-nav-next:hover {
  background: var(--bg-secondary);
  border-color: var(--border-medium);
}
.post-nav .nav-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
  font-weight: 500;
}
/* 디자인 시스템 — 블로그명의 syntax 컬러를 hint 로 */
.post-nav-prev .nav-meta { color: var(--syntax-keyword); }   /* 'return' 보라 */
.post-nav-next .nav-meta { color: var(--syntax-class); }     /* 'Story' 파랑 */
.post-nav-prev:hover { border-color: var(--syntax-keyword); }
.post-nav-next:hover { border-color: var(--syntax-class); }
.post-nav .nav-title {
  font-size: var(--fs-sm);
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -----------------------------------------
   Comments
   ----------------------------------------- */
.comments {
  max-width: var(--article-max);
  margin: 56px auto 0;
  padding-top: 32px;
  border-top: 0.5px solid var(--border-light);
}
.comments-title {
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 20px;
}
.comments-count {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  margin-left: 4px;
}
.comment-list { display: flex; flex-direction: column; gap: 20px; margin-bottom: 28px; }
.comment {
  padding: 14px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 0.5px solid var(--border-light);
}
.comment-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.comment-name { font-size: var(--fs-sm); font-weight: 500; color: var(--text-primary); }
/* 옛 댓글은 작성자명 데이터가 비어있는 경우가 있어 fallback 으로 "익명" 표시 */
.comment-name:empty::before {
  content: '익명';
  color: var(--text-tertiary);
  font-weight: 400;
  font-style: italic;
}
.comment-date { font-size: 11px; color: var(--text-tertiary); }

/* 비밀댓글 뱃지 — JS 가 본문의 "[비밀댓글]" 텍스트를 인지하면 .comment-meta 에 주입 */
.comment-secret-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.comment-secret-badge svg { display: block; }
.comment-body { font-size: var(--fs-sm); line-height: 1.6; color: var(--text-secondary); }
.comment-replies { margin-top: 14px; padding-left: 14px; border-left: 0.5px solid var(--border-light); display: flex; flex-direction: column; gap: 14px; }
.comment-reply { background: var(--bg-primary); }

/* 댓글 폼 — Tistory 가 우리 <form class="comment-form"> 을 자체 form 으로 교체할 수 있어
   .comments form / .comments textarea 로도 매칭하도록 셀렉터 글로벌화 */
.comment-form,
.comments form { display: flex; flex-direction: column; gap: 10px; }
.comments input[type="text"],
.comments input[type="password"],
.comments textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 0.5px solid var(--border-light);
  border-radius: 6px;
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color .15s ease;
  box-sizing: border-box;
}
.comments input[type="text"]:focus,
.comments input[type="password"]:focus,
.comments textarea:focus { border-color: var(--text-primary); }
.comments textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.6;
  font-family: inherit;
}
.comment-form-guest {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.comment-form-guest p { margin: 0; }
.comment-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

/* Tistory 가 .comments 안에 자동 삽입하는 카카오 프로필 카드(blogger 프로필) 숨김.
   .comments 의 첫 직속 div 가 보통 그 카드 (회색 박스). 우리 <s_rp> wrapping 은
   다른 자식들을 더 갖고 있으므로 :has() 로 form/h2 가 없는 첫 div 만 hide. */
.comments > div:first-child:not(:has(form)):not(:has(.comment-list)):not(:has(.comments-title)) {
  display: none;
}

/* Tistory 의 React 가 .comment-list 안에 주입하는 댓글 마크업
   (tt-cmt / tt-link-user / tt-box-meta / tt-comment-cont …) 에 대한 안전망 스타일.
   <s_rp_rep> 템플릿이 dead code 화 되어 우리가 직접 통제 불가 → 최소한의 톤만 잡음. */
.comment-list .tt-link-user {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
}
.comment-list .tt-link-user:hover { text-decoration: underline; text-underline-offset: 2px; }
.comment-list .tt-box-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.comment-list .tt-comment-cont {
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
}
/* 익명 댓글이면 .tt-link-user 가 텍스트 없는 빈 <a> 가 됨 → 빈 박스로 자리만 차지하지 않게 */
.comment-list .tt-link-user:empty { display: none; }

/* "더보기" 버튼 (수정/삭제/신고/링크복사 메뉴 트리거)
   Tistory React 가 className 만 박고 스타일은 스킨에 위임. 글로벌 button 리셋
   때문에 안 보이던 걸 명시적으로 복원. */
.comment-list .tt-box-modify { position: relative; display: inline-block; margin-left: auto; }
.comment-list .tt-button-modify {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 22px;
  border-radius: 4px;
  font-size: 0;
  line-height: 1;
  color: var(--text-tertiary);
  transition: background .12s ease, color .12s ease;
}
.comment-list .tt-button-modify::before {
  content: "⋯";
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0;
}
.comment-list .tt-button-modify:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* 더보기 드롭다운 메뉴 */
.comment-list .tt-list-modify {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--bg-primary);
  border: 0.5px solid var(--border-medium);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  z-index: 20;
  min-width: 110px;
  display: none;
}
.comment-list .tt-box-modify-open .tt-list-modify { display: block; }
.comment-list .tt-list-modify li { margin: 0; list-style: none; }
.comment-list .tt-list-modify button,
.comment-list .tt-list-modify a {
  display: block;
  width: 100%;
  padding: 7px 14px;
  text-align: left;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  white-space: nowrap;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.comment-list .tt-list-modify button:hover,
.comment-list .tt-list-modify a:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* "더보기" 버튼이 .tt-box-meta 안에 들어오면서 끝쪽으로 정렬 */
.comment-list .tt-box-meta { position: relative; }
.comment-list .tt-box-meta .tt-box-modify { margin-left: auto; }
.comment-form-secret {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: auto;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  cursor: pointer;
}
.comment-form-secret input[type="checkbox"] { margin: 0; }
.comment-form-actions input[type="submit"],
.comment-form-actions button {
  padding: 9px 18px;
  background: var(--text-primary);
  color: var(--bg-primary);
  border: 0;
  border-radius: 6px;
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s ease;
}
.comment-form-actions input[type="submit"]:hover,
.comment-form-actions button:hover { opacity: 0.85; }

/* -----------------------------------------
   List page (search/tag/archive)
   ----------------------------------------- */
.list-page { max-width: var(--article-max); margin: 0 auto; }
.list-header { margin-bottom: 28px; padding-bottom: 18px; border-bottom: 0.5px solid var(--border-light); }
.list-title {
  font-size: var(--fs-lg);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-top: 6px;
}
.post-list { display: flex; flex-direction: column; }
.post-list-item { border-bottom: 0.5px solid var(--border-light); }
.post-list-item:last-child { border-bottom: 0; }
.post-list-item a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 14px 0;
  transition: opacity .15s ease;
}
.post-list-item a:hover { opacity: 0.65; }
.post-list-title { font-size: var(--fs-sm); color: var(--text-primary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-list-meta { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); white-space: nowrap; }

/* -----------------------------------------
   Paging
   ----------------------------------------- */
.paging {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
.paging-top {
  justify-content: flex-end;
}
.paging-bottom {
  justify-content: center;
  margin: 56px auto 0;
}
.page-num,
.page-step {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: background .15s ease, color .15s ease;
}
.page-num:hover,
.page-step:hover { background: var(--bg-tertiary); color: var(--text-primary); }
/* 현재 페이지 강조 — Tistory 가 [##_paging_rep_link_num_##] 를
   <span class="selected"> 또는 <span class=""> 으로 출력 */
.page-num:has(.selected),
.page-num.selected,
.page-num[class*="paging_selected"] {
  background: var(--text-primary);
  color: var(--bg-primary);
}
.page-num .selected {
  display: inline-block;
  font-weight: 500;
}
/* prev/next 비활성 — 첫/마지막 페이지에서 [##_no_more_prev_##] / [##_no_more_next_##] 가
   클래스로 들어옴. 정확한 클래스명을 모르므로 "no_more" 키워드를 부분매칭 처리. */
.page-step[class*="no_more"],
.page-step[class*="no-more"],
.page-step:empty,
.page-step:not([href]) {
  pointer-events: none;
  opacity: 0.3;
}

/* -----------------------------------------
   Footer
   ----------------------------------------- */
.site-footer {
  margin-top: 96px;
  border-top: 0.5px solid var(--border-light);
  background: var(--bg-secondary);
  /* fixed 사이드바(z:5)가 위로 올라오는 걸 가림 */
  position: relative;
  z-index: 10;
}
.footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 28px var(--gutter-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0;
}
.footer-meta .meta-item { color: var(--text-tertiary); text-decoration: none; }
.footer-meta a.meta-item:hover { color: var(--text-primary); }
.footer-meta .meta-sep { color: var(--text-muted); user-select: none; }

/* Instagram (또는 임의 STRING 변수가 비었을 때) 자동 숨김 — `:has()` 로 직전 구분점도 같이 사라지게 */
.footer-meta a[href=""] { display: none; }
.footer-meta .meta-sep:has(+ a[href=""]) { display: none; }

.footer-social {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.footer-social svg { display: block; opacity: .9; }
.footer-social:hover svg { opacity: 1; }
.footer-brand {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
}
.footer-brand .kw  { color: var(--syntax-keyword); }
.footer-brand .cls { color: var(--syntax-class); }

/* -----------------------------------------
   Legal modal — 개인정보 처리방침 (`:target` 토글)
   - DOM 에 항상 존재 (AdSense 봇이 본문 텍스트 그대로 읽을 수 있게)
   - `display: none` 대신 `visibility + opacity` 로 시각적 숨김만 처리
   ----------------------------------------- */
.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  visibility: hidden;
  opacity: 0;
  transition: opacity .18s ease, visibility 0s linear .18s;
}
.legal-modal:target {
  visibility: visible;
  opacity: 1;
  transition: opacity .18s ease, visibility 0s;
}
.legal-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, .45);
  cursor: pointer;
}
.legal-modal-panel {
  position: relative;
  z-index: 1;
  margin: 5vh auto;
  max-width: 640px;
  max-height: 90vh;
  background: var(--bg-primary);
  border: 0.5px solid var(--border-light);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .12);
  overflow: hidden;
}
.legal-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 0.5px solid var(--border-light);
}
.legal-modal-head h2 {
  font-size: var(--fs-md);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}
.legal-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background .15s ease;
}
.legal-modal-close:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.legal-modal-body {
  padding: 22px 24px 28px;
  overflow-y: auto;
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--text-secondary);
}
.legal-modal-body h3 {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-primary);
  margin: 18px 0 6px;
  letter-spacing: -0.01em;
}
.legal-modal-body h3:first-of-type { margin-top: 4px; }
.legal-modal-body p { margin: 0 0 10px; }
.legal-modal-body a { color: var(--text-primary); text-decoration: underline; text-underline-offset: 2px; }
.legal-modal-body em { font-family: var(--font-mono); font-style: normal; font-size: 12.5px; }
.legal-modal-effective {
  margin-top: 18px !important;
  padding-top: 14px;
  border-top: 0.5px solid var(--border-light);
  color: var(--text-tertiary);
  font-size: 12px;
}

@media (max-width: 767px) {
  .legal-modal-panel {
    margin: 0;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border: none;
  }
  .legal-modal-head { padding: 16px 18px; }
  .legal-modal-body { padding: 18px 18px 24px; }
}

/* -----------------------------------------
   Responsive
   ----------------------------------------- */

/* Tablet — 사이드바 → 햄버거, 카드 2열 유지 */
@media (max-width: 1023px) {
  .layout {
    grid-template-columns: 1fr;
    max-width: calc(var(--article-max) + var(--gutter-sm) * 2);
    padding: 24px var(--gutter-sm) 56px;
  }
  body[data-sidebar="0"] .layout { /* same as default mobile */ }
  /* 데스크톱 .main { grid-column: 2 } 때문에 모바일에서 본문이 우측 쏠림 → 1열로 강제 */
  .main { grid-column: 1; }

  .nav-toggle { display: inline-block; }
  .nav-main { display: none; }
  .header-inner { grid-template-columns: auto 1fr; }
  .brand { justify-self: end; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-height: none;
    z-index: 100;
    background: var(--bg-primary);
    padding: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow: hidden;        /* 자체 스크롤 X — 안의 .sidebar-inner 만 스크롤 */
    display: flex;
    flex-direction: column;
  }
  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 var(--gutter-sm);
    border-bottom: 0.5px solid var(--border-light);
    flex-shrink: 0;
    background: var(--bg-primary);
    /* flex 첫 자식이라 자연히 위에 고정 — sticky 없이 OK */
  }
  .sidebar-header .brand-mobile { font-size: 14px; }
  .sidebar-close {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px;
    color: var(--text-primary);
    transition: background .15s ease;
  }
  .sidebar-close:hover { background: var(--bg-tertiary); }
  .sidebar-inner {
    flex: 1;
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
    padding: 24px var(--gutter-sm) 32px;
  }
  /* 풀스크린 드로어라 backdrop 불필요 */
  .drawer-backdrop { display: none !important; }
  .sidebar[data-open="true"] { transform: translateX(0); }
  body[data-sidebar="0"] .sidebar { display: flex; } /* 모바일에선 옵션 무시 */
}

/* Mobile — 카드 1열, 패딩 축소 */
@media (max-width: 767px) {
  :root {
    --gutter-sm: 16px;
    --header-h: 52px;
  }
  body { font-size: 15px; }

  .header-inner { padding: 0 var(--gutter-sm); gap: 8px; }
  .brand { font-size: 14px; }

  /* 모바일에서는 subtitle 만 우측 정렬 — 다른 요소는 영향 X */
  .site-subtitle { text-align: right; }

  .layout { padding: 20px var(--gutter-sm) 40px; gap: 32px; }

  .post-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .notice-card-link { grid-template-columns: 1fr; gap: 14px; }
  .notice-card-thumb { aspect-ratio: 16 / 10; }
  .notice-card-title { font-size: var(--fs-md); }

  .paging-top { display: none; }
  .paging-bottom { margin-top: 40px; }
  /* 인덱스 모바일: list-header 안에 표시할 게 둘 다 없음 → 통째로 숨김 */
  #tt-body-index .list-header { display: none; }

  .post-title { font-size: 24px; }
  .post-body { font-size: 15px; }
  .post-body h2 { font-size: 20px; }
  .post-body h3 { font-size: 17px; }
  .post-body pre { padding: 14px 14px; font-size: 12.5px; }

  .post-nav { grid-template-columns: 1fr; }
  .comment-form-guest { grid-template-columns: 1fr; }

  .footer-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}
