:root {
  --bg: #0b0b0d;
  --panel: #17171a;
  --panel-2: #1f1f24;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --primary: #f5b78f;
  --primary-muted: #7c5d4a;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #f87171;
  --blue: #60a5fa;
  --tag-bg: #27272a;
  --code-bg: #131316;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --font-sans: 'Apple SD Gothic Neo', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.7;
  min-height: 100vh;
}

/* ── Layout ── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  background: rgba(11, 11, 13, 0.85);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.site-header .inner {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-title span { color: var(--primary); }

nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-left: 1.5rem;
  transition: color 0.2s;
}

nav a:hover { color: var(--text); }

.site-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

.site-main > article {
  max-width: 760px;
  margin: 0 auto;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  display: inline-block;
  padding: 0.75rem 0.5rem;
}

/* ── Index Page ── */
.page-hero {
  padding: 2.5rem 0 1.25rem;
}

.page-hero h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.4rem;
}

.page-hero p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* 영문판처럼 아직 글이 없는 목록 */
.post-list-empty {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 1rem 0;
}

/* ── Category Top Menu ── */
.cat-menu {
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.cat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
}

.cat-row-main { padding: 0.6rem 0; }

.cat-subrow {
  padding: 0 0 0.7rem 0.4rem;
  gap: 0.35rem;
}

.cat-subrow[hidden] { display: none; }

.cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.cat-btn:hover { color: var(--text); background: var(--panel); }
.cat-btn.active { color: var(--primary); }

.cat-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
}

.cat-btn.active .cat-count { color: var(--primary); }

.cat-btn-sub {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  padding: 0.25rem 0.6rem;
}

.cat-btn-sub.active { color: var(--primary); }

.cat-chevron {
  transition: transform 0.2s ease;
  opacity: 0.55;
}

.cat-btn[aria-expanded="true"] .cat-chevron { transform: rotate(90deg); }

/* ── Post List (one-line list) ── */
.post-list {
  display: flex;
  flex-direction: column;
}

@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.post-row {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 0.85rem 0.5rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  animation: rowFadeIn 0.35s ease both;
}

.post-row:hover { background: var(--panel); }

/* 지금 보고 있는 글 — 목록에서 어디에 있는지 바로 보이게 */
.post-row.is-current {
  background: var(--panel);
  box-shadow: inset 2px 0 0 var(--primary);
}

.post-row.is-current .post-row-title { color: var(--primary); }

.post-row-eyebrow {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.post-row-title {
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
  margin-bottom: 0.2rem;
}

.post-row:hover .post-row-title { color: var(--primary); }

.post-row-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.3rem;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-row-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ── Pagination ── */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}

.pager[hidden] { display: none; }

.pager-btn {
  display: inline-block;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.pager-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--panel);
}

.pager-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.pager-info {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.tag {
  background: var(--tag-bg);
  color: var(--text);
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
}

/* ── Post Page ── */
.post-header {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

/* 본문이 DOM 에서 목록보다 앞에 오고(검색엔진용), 화면에서는 접힌 목록 한 줄이 위로 돌아온다 */
.post-page { display: flex; flex-direction: column; }
.post-page > .post-browse { order: -1; }
/* 목록에서 다른 글을 고르면 #postView 로 스크롤한다 — 고정 헤더(모바일에선 두 줄)에 제목이 가리지 않게 띄운다 */
#postView { scroll-margin-top: 6.5rem; }

/* 포스트 위의 접힌 목록 — 펼쳤을 때만 아래 여백을 크게 준다 */
.post-browse {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.post-browse[open] { margin-bottom: 2.5rem; padding-bottom: 1.5rem; }

.post-browse-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.post-browse-toggle::-webkit-details-marker { display: none; }
.post-browse-toggle:hover { color: var(--text); }
.post-browse[open] .post-browse-toggle .cat-chevron { transform: rotate(90deg); }

.post-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* 카테고리 배지는 모두 같은 모양 — 카테고리가 늘어도 규칙을 추가하지 않는다 */
.badge-cat { background: var(--panel); color: var(--text-muted); border: 1px solid var(--border); }
.badge-sub { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }

/* ── Post Content ── */
/* 본문 17px — 760px 폭에서 한 줄 약 43자로 한글 적정 구간(35~45자)에 들어온다.
   색은 --text(#fafafa) 대신 한 단계 낮춘다: 다크 배경의 순백은 헤일레이션을 만든다.
   대비 15.9:1 로 AAA(7:1) 를 여전히 두 배 이상 넘긴다. */
.post-content {
  max-width: 100%;
  font-size: 1.0625rem;
  line-height: 1.8;
  color: #e8e8ea;
}

.post-content h2 {
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 2.25rem 0 0.9rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.02em;
  color: var(--text);
}

/* 이식 글의 `▸` 소제목이 전부 h3 다 — 본문과 같은 크기·흐린 색이면 위계가 뒤집힌다 */
.post-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 1.75rem 0 0.6rem;
  color: var(--text);
}

/* 문단 간격은 줄 간격(≈30px)보다 넓어야 덩어리로 분리돼 보인다 */
.post-content p { margin-bottom: 1.4rem; }

.post-content img {
  display: block;
  max-width: min(100%, 560px);
  height: auto;
  margin: 1.5rem auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* 이미지 바로 뒤의 이탤릭 한 줄 = 캡션 (![](){newline}*캡션* 패턴) */
.post-content p > img + em {
  display: block;
  margin: -1rem auto 1.5rem;
  max-width: min(100%, 560px);
  font-size: 0.8rem;
  font-style: normal;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* 형광펜 강조 — 네이버 원문의 ==하이라이트== 가 <mark> 로 변환된다 */
.post-content mark {
  background: rgba(255, 214, 0, 0.16);
  color: var(--text);
  padding: 0.05em 0.2em;
  border-radius: 3px;
  box-decoration-break: clone;
}

.post-content blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1.1rem;
  border-left: 3px solid var(--border);
  background: var(--panel);
  border-radius: 0 6px 6px 0;
  color: var(--text-muted);
}

.post-content blockquote > :last-child { margin-bottom: 0; }

.post-content ul, .post-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.4rem;
}

.post-content li { margin-bottom: 0.25rem; }

.post-content strong { color: var(--text); font-weight: 600; }

/* 본문 텍스트와 같은 흰색이면 밑줄로만 구분된다 — 외부 링크가 389개다 */
.post-content a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content a:hover { color: var(--text); }

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  color: #f97583;
}

.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.4rem;
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 0.875rem;
}

/* ── Code Box Mac UI ── */
.code-window {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.code-header {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border);
}

.mac-dots {
  display: flex;
  gap: 6px;
  margin-right: 15px;
}

.mac-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.mac-dots span:nth-child(1) { background: #ff5f56; }
.mac-dots span:nth-child(2) { background: #ffbd2e; }
.mac-dots span:nth-child(3) { background: #27c93f; }

.code-lang-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-window pre {
  margin: 0;
  border: none;
  border-radius: 0;
}

.post-content .mermaid {
  display: flex;
  justify-content: center;
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
}

.post-content .mermaid .edgeLabel,
.post-content .mermaid .edgeLabel rect,
.post-content .mermaid .edgeLabel p,
.post-content .mermaid .edgeLabel span {
  background-color: transparent !important;
  fill: transparent !important;
  color: var(--text) !important;
}

.post-content .mermaid .edgeLabel p,
.post-content .mermaid .edgeLabel span,
.post-content .mermaid .edgeLabel foreignObject div {
  color: var(--text) !important;
  font-weight: 600;
  text-shadow:
    0 0 4px var(--panel),
    0 0 4px var(--panel),
    0 0 4px var(--panel);
}

.post-content .mermaid svg {
  max-width: 100%;
  height: auto;
}

/* ── Tables ── */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.post-content th {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.6rem 0.85rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.post-content td {
  border: 1px solid var(--border);
  padding: 0.6rem 0.85rem;
  vertical-align: top;
}

.post-content tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ── Callout ── */
.callout {
  position: relative;
  background:
    linear-gradient(135deg, rgba(224, 184, 150, 0.08) 0%, rgba(44, 63, 88, 0.0) 60%),
    var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 1.1rem 1.35rem 1.1rem 1.5rem;
  margin: 1.75rem 0;
  box-shadow:
    0 0 0 1px rgba(224, 184, 150, 0.08),
    0 6px 20px -8px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.callout::before {
  content: "";
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -4px;
  width: 4px;
  background: var(--primary);
  box-shadow: 0 0 12px rgba(224, 184, 150, 0.55);
  border-radius: 2px;
}

.callout.why { border-left-color: var(--primary); }

.callout-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--primary);
  margin-bottom: 0.55rem;
}

.callout-title::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 2px;
  background: var(--primary);
  box-shadow: 0 0 8px rgba(224, 184, 150, 0.8);
  flex-shrink: 0;
}

.callout.why .callout-title { color: var(--primary); }

.callout p { margin-bottom: 0.5rem; }
.callout p:last-child { margin-bottom: 0; }
.callout code {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(224, 184, 150, 0.25);
}

/* ── Resume ── */
.resume-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

.resume-content h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
}

.resume-content h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.resume-content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.25rem;
  color: var(--text);
}

.resume-content h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 1rem 0 0.25rem;
}

.resume-content p {
  margin-bottom: 0.75rem;
  line-height: 1.7;
}

.resume-content ul, .resume-content ol {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.resume-content li {
  margin-bottom: 0.3rem;
  line-height: 1.6;
}

.resume-content li::marker {
  color: var(--text-muted);
}

.resume-content strong {
  color: var(--text);
  font-weight: 600;
}

.resume-content em {
  color: var(--text-muted);
  font-style: normal;
}

.resume-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.resume-content a {
  color: var(--primary);
  text-decoration: none;
}

.resume-content a:hover {
  text-decoration: underline;
}

.resume-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  color: var(--text-muted);
}

.resume-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.resume-content th {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.resume-content td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  vertical-align: top;
}

.resume-content blockquote {
  border-left: 3px solid var(--border);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
}

@media print {
  .site-header, .site-footer { display: none; }
  .resume-main { padding: 0; max-width: 100%; }
  body { background: #fff; color: #111; }
  .resume-content h2 { border-bottom-color: #ccc; }
  .resume-content a { color: #111; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .site-main { padding: 2rem 1.25rem 3rem; }
}

@media (max-width: 640px) {
  /* 로고와 메뉴 5개가 한 줄에 안 들어가므로 두 줄로 쌓고, 메뉴가 넘치면 가로로 민다 */
  .site-header { padding: 0.75rem 0; }
  .site-header .inner { padding: 0 1.25rem; flex-direction: column; align-items: flex-start; gap: 0.35rem; }
  nav { display: flex; gap: 1.1rem; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  nav a { margin-left: 0; white-space: nowrap; }
  .post-row-title { font-size: 0.98rem; }
  .post-header h1 { font-size: 1.4rem; }
  .page-hero h1 { font-size: 1.5rem; }
}
