: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;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── Sidebar Toggle Button ── */
.sidebar-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
}

.sidebar-toggle span {
  display: block;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: all 0.2s;
}

.sidebar-toggle:hover span { background: var(--text); }

.sidebar-toggle.collapsed span:nth-child(1) { width: 100%; }
.sidebar-toggle.collapsed span:nth-child(2) { width: 70%; }
.sidebar-toggle.collapsed span:nth-child(3) { width: 100%; }

.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-body {
  display: flex;
  align-items: flex-start;
}

/* ── Sidebar ── */
.site-sidebar {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: 57px;
  padding: 1.75rem 1.25rem 4rem;
  max-height: calc(100vh - 57px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  transition: width 0.25s ease, padding 0.25s ease, opacity 0.2s ease;
}

.site-body.sidebar-closed .site-sidebar {
  width: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  border-right: none;
  pointer-events: none;
}

.sidebar-section {
  margin-bottom: 1.25rem;
}

.sidebar-label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  padding: 0.4rem 0.5rem;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.sidebar-label .sidebar-chevron {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
}

.sidebar-label[aria-expanded="true"] {
  color: var(--text);
}

.sidebar-label[aria-expanded="true"] .sidebar-chevron {
  transform: translateY(-50%) rotate(90deg);
}

.sidebar-label:hover {
  color: var(--text);
  background: var(--panel);
}

.sidebar-chevron {
  transition: transform 0.25s ease;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding-left: 0.25rem;
}

.sidebar-body.is-open {
  max-height: none;
}

body.preload .sidebar-body,
body.preload .sidebar-chevron,
body.preload .site-sidebar,
body.preload .site-body {
  transition: none !important;
}

.sidebar-subcategory {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0.75rem 0 0.25rem 0.5rem;
}

.sidebar-subcategory.has-posts {
  color: var(--text-muted);
}

.sidebar-link {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  line-height: 1.4;
  transition: color 0.15s, background 0.15s;
}

.sidebar-link:hover {
  color: var(--text);
  background: var(--panel);
}

.sidebar-link.active {
  color: var(--text);
  background: var(--panel-2);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--primary);
}

.site-main {
  flex: 1;
  min-width: 0;
  padding: 2.5rem 3rem 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;
}

/* ── Index Page ── */
.page-hero {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

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

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

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

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

.post-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.2s, transform 0.15s;
  animation: cardFadeUp 0.4s ease both;
}

.post-card:nth-child(1) { animation-delay: 0s; }
.post-card:nth-child(2) { animation-delay: 0.06s; }
.post-card:nth-child(3) { animation-delay: 0.12s; }
.post-card:nth-child(4) { animation-delay: 0.18s; }
.post-card:nth-child(5) { animation-delay: 0.24s; }
.post-card:nth-child(6) { animation-delay: 0.3s; }
.post-card:nth-child(n+7) { animation-delay: 0.36s; }

.post-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.post-card-category {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.post-card h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.post-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

.post-card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.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;
}

.post-breadcrumb {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.post-breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.post-breadcrumb a:hover { text-decoration: underline; }

.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-ci-cd,
.badge-container---orchestration,
.badge-cloud-infrastructure,
.badge-observability,
.badge-devops---sre,
.badge-development,
.badge-architecture { 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); }

/* ── Category Filter ── */
.category-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.filter-btn {
  background: var(--panel);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.35rem 0.9rem;
  font-size: 0.82rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.filter-btn.active {
  background: var(--panel);
  color: var(--text);
  border-color: var(--text-muted);
  font-weight: 600;
}

.post-card-subcategory {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: -0.25rem;
}

/* ── Post Content ── */
.post-content { max-width: 100%; }

.post-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.02em;
}

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

.post-content p { margin-bottom: 1rem; }

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

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

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

.post-content a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.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: 1rem;
}

.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);
}

/* ── Post Nav ── */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.post-nav a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
  max-width: 45%;
}

.post-nav a:hover { text-decoration: underline; }

.post-nav .prev::before { content: "← "; }
.post-nav .next::after  { content: " →"; }

/* ── 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-sidebar {
    position: fixed;
    top: 57px;
    left: 0;
    height: calc(100vh - 57px);
    background: var(--bg);
    z-index: 50;
    box-shadow: 4px 0 12px rgba(0,0,0,0.4);
  }
  .site-body.sidebar-closed .site-sidebar {
    width: 0;
    padding: 0;
  }
  .site-main { padding: 2rem 1.25rem 3rem; }
}

@media (max-width: 640px) {
  .posts-grid { grid-template-columns: 1fr; }
  .post-header h1 { font-size: 1.4rem; }
  .page-hero h1 { font-size: 1.5rem; }
}
