:root {
  --bg: #0b0d10;
  --surface: #11151a;
  --surface-2: #171c22;
  --text: #eef2f6;
  --muted: #929ba7;
  --line: #252c34;
  --accent: #a3ff12;
  --accent-soft: rgba(163, 255, 18, .10);
  --code: #0a0c0f;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
  --max: 1120px;
}

html[data-theme="light"] {
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-2: #ecefe7;
  --text: #151815;
  --muted: #687066;
  --line: #dce1d8;
  --accent: #4d7c0f;
  --accent-soft: rgba(77, 124, 15, .09);
  --code: #1c211d;
  --shadow: 0 24px 70px rgba(36, 45, 29, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
  transition: background .2s ease, color .2s ease;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }
::selection { background: var(--accent); color: #0b0d10; }

.page-shell { width: min(calc(100% - 40px), var(--max)); margin: 0 auto; }
.site-header {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; gap: 10px; align-items: center; font-weight: 800; letter-spacing: -.04em; }
.brand-mark { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.site-nav { display: flex; align-items: center; gap: 26px; color: var(--muted); font-size: 14px; font-weight: 650; }
.site-nav a { transition: color .15s ease; }
.site-nav a:hover { color: var(--text); }
.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer;
}

.hero {
  min-height: 650px;
  padding: 96px 0 82px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr);
  gap: 72px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.eyebrow { margin: 0 0 18px; color: var(--accent); font: 700 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; }
.hero h1, .about-page > h1 {
  margin: 0;
  font-size: clamp(48px, 7vw, 86px);
  line-height: .99;
  letter-spacing: -.065em;
  font-weight: 850;
}
.hero h1 span { color: var(--muted); }
.hero-description { max-width: 650px; margin: 30px 0 0; color: var(--muted); font-size: 17px; }
.hero-actions { margin-top: 34px; display: flex; align-items: center; gap: 24px; }
.primary-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 14px;
  min-height: 48px; padding: 0 20px; background: var(--accent); color: #0d100a;
  border-radius: 9px; font-weight: 800; font-size: 14px;
  transition: transform .15s ease, filter .15s ease;
}
.primary-button:hover { transform: translateY(-2px); filter: brightness(1.05); }
.text-link { color: var(--muted); font-size: 14px; font-weight: 700; }
.text-link:hover { color: var(--text); }

.terminal-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); transform: rotate(1.5deg); }
.terminal-bar { height: 44px; padding: 0 15px; display: flex; align-items: center; gap: 7px; border-bottom: 1px solid var(--line); color: var(--muted); font: 600 11px/1 ui-monospace, monospace; }
.terminal-bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.terminal-bar span { margin-left: 8px; }
.terminal-card pre { margin: 0; padding: 28px; overflow: auto; }
.terminal-card code { color: var(--text); font: 13px/1.9 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.prompt { color: var(--accent); }
.cursor { color: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.posts-section { padding: 92px 0 110px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 34px; }
.section-heading h2 { margin: 0; font-size: clamp(34px, 5vw, 52px); letter-spacing: -.045em; }
.post-count { color: var(--muted); font: 600 12px/1 ui-monospace, monospace; }
.post-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.post-card { position: relative; min-height: 290px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.post-card:hover { transform: translateY(-4px); border-color: var(--accent); background: var(--surface-2); }
.post-card-link { position: absolute; inset: 0; z-index: 1; }
.post-meta { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font: 700 11px/1.3 ui-monospace, monospace; text-transform: uppercase; letter-spacing: .08em; }
.post-meta span { color: var(--accent); }
.post-card h3 { margin: 34px 0 12px; font-size: 26px; line-height: 1.24; letter-spacing: -.035em; }
.post-card > p { margin: 0; color: var(--muted); font-size: 14px; }
.post-card-footer { position: absolute; left: 28px; right: 28px; bottom: 25px; display: flex; align-items: end; justify-content: space-between; }
.arrow { font-size: 22px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { display: inline-flex; padding: 6px 9px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font: 650 11px/1 ui-monospace, monospace; }
.compact { position: relative; z-index: 2; }
.empty-state { padding: 70px 30px; border: 1px dashed var(--line); border-radius: 14px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 12px 0 4px; color: var(--text); font-size: 24px; }
.empty-icon { color: var(--accent); font-size: 34px; }

.post-page { max-width: 800px; margin: 0 auto; padding: 70px 0 110px; }
.back-link { color: var(--muted); font-size: 13px; font-weight: 700; }
.back-link:hover { color: var(--accent); }
.post-header { padding: 64px 0 52px; border-bottom: 1px solid var(--line); }
.post-kicker { display: flex; justify-content: space-between; color: var(--muted); font: 700 11px/1 ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; }
.post-kicker span { color: var(--accent); }
.post-header h1 { margin: 22px 0 18px; font-size: clamp(42px, 7vw, 70px); line-height: 1.06; letter-spacing: -.055em; }
.post-description { margin: 0 0 24px; color: var(--muted); font-size: 18px; }
.post-content { padding: 52px 0; font-size: 17px; }
.post-content h2 { margin: 56px 0 18px; font-size: 31px; letter-spacing: -.035em; }
.post-content h3 { margin: 38px 0 14px; font-size: 23px; }
.post-content p, .post-content ul, .post-content ol { color: var(--text); }
.post-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.post-content blockquote { margin: 28px 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--accent); color: var(--muted); }
.post-content img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.post-content :not(pre) > code { padding: 3px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font: .88em ui-monospace, monospace; }
.post-content pre { overflow-x: auto; margin: 28px 0; padding: 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--code); color: #e9edf1; }
.post-content pre code { font: 13px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.post-content table {
  width: 100%;
  margin: 28px 0;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  font-size: 14px;
}
.post-content th,
.post-content td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
.post-content th:first-child,
.post-content td:first-child { text-align: left; }
.post-content th {
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .01em;
}
.post-content tbody tr:last-child td { border-bottom: 0; }
.post-content tbody tr:hover { background: var(--accent-soft); }
.post-end { display: flex; justify-content: space-between; padding-top: 28px; border-top: 1px solid var(--line); color: var(--muted); font: 700 12px/1 ui-monospace, monospace; }
.post-end span { color: var(--accent); }

.about-page { padding: 100px 0 110px; }
.about-page > h1 { max-width: 880px; }
.about-lead { max-width: 720px; margin: 36px 0 76px; color: var(--muted); font-size: 19px; }
.about-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.about-panel { padding: 34px 30px 42px 0; }
.about-panel + .about-panel { padding-left: 30px; border-left: 1px solid var(--line); }
.panel-number { color: var(--accent); font: 700 11px/1 ui-monospace, monospace; }
.about-panel h2 { margin: 28px 0 10px; font-size: 23px; }
.about-panel p { margin: 0; color: var(--muted); font-size: 14px; }
.about-cta { margin-top: 90px; padding: 40px; display: flex; justify-content: space-between; align-items: center; gap: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.about-cta h2 { margin: 0; font-size: 30px; letter-spacing: -.035em; }

.not-found { min-height: 620px; display: flex; flex-direction: column; justify-content: center; align-items: start; }
.not-found h1 { margin: 0; font-size: clamp(46px, 8vw, 80px); letter-spacing: -.055em; }
.not-found > p:not(.eyebrow) { margin: 16px 0 28px; color: var(--muted); }

.site-footer { min-height: 130px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.site-footer div { display: flex; align-items: center; gap: 12px; }
.site-footer strong { color: var(--text); }

@media (max-width: 850px) {
  .hero { grid-template-columns: 1fr; gap: 54px; padding: 72px 0; }
  .terminal-card { max-width: 560px; transform: none; }
  .post-grid { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
  .about-panel { padding: 30px 0; }
  .about-panel + .about-panel { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .post-content { overflow-x: auto; }
  .post-content table { min-width: 680px; }
}

@media (max-width: 620px) {
  .page-shell { width: min(calc(100% - 28px), var(--max)); }
  .site-header { min-height: 72px; }
  .site-nav { gap: 14px; }
  .site-nav a:nth-child(2) { display: none; }
  .hero { min-height: auto; padding: 62px 0; }
  .hero h1, .about-page > h1 { font-size: clamp(44px, 14vw, 64px); }
  .hero-description { font-size: 15px; }
  .hero-actions { align-items: flex-start; flex-direction: column; gap: 16px; }
  .terminal-card pre { padding: 22px 20px; }
  .posts-section { padding: 68px 0 80px; }
  .post-card { min-height: 310px; padding: 24px; }
  .post-card-footer { left: 24px; right: 24px; }
  .post-page { padding-top: 50px; }
  .post-header { padding-top: 46px; }
  .post-content { font-size: 16px; }
  .post-content table { min-width: 640px; }
  .about-page { padding: 72px 0 80px; }
  .about-lead { margin-bottom: 50px; font-size: 17px; }
  .about-cta { margin-top: 62px; padding: 28px; align-items: flex-start; flex-direction: column; }
  .site-footer { padding: 32px 0; align-items: flex-start; flex-direction: column; justify-content: center; gap: 12px; }
  .site-footer div { align-items: flex-start; flex-direction: column; gap: 3px; }
}

/* Mermaid diagrams share the post theme; preserve readable type on small screens. */
.post-diagram {
  margin: 2rem 0;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
}
.post-diagram > figcaption {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
}
.diagram-canvas {
  width: 100%;
  overflow-x: auto;
  padding: .5rem 0 1rem;
  overscroll-behavior-x: contain;
}
.diagram-canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.diagram-canvas svg { display: block; margin: 0 auto; }
.post-content .diagram-canvas text { font-family: Inter, Pretendard, sans-serif; }
.diagram-source { border-top: 1px solid var(--line); padding-top: .75rem; }
.diagram-source summary { cursor: pointer; color: var(--muted); font-size: .8rem; }
.post-content .diagram-source pre { margin: .75rem 0 0; white-space: pre; }
.post-content .diagram-status { color: var(--muted); font-size: .85rem; }
@media (max-width: 600px) {
  .post-diagram { padding: .8rem; margin: 1.5rem 0; border-radius: 12px; }
}

/* Keep comparisons as tables, but let explanatory cells wrap naturally. */
.post-content { overflow-wrap: anywhere; }
.post-content th, .post-content td {
  text-align: left;
  white-space: normal;
  vertical-align: top;
}
.post-content th[style*="text-align: right"],
.post-content td[style*="text-align: right"] { white-space: nowrap; }
.post-table-scroll {
  margin: 28px 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.post-content .post-table-scroll table { margin: 0; min-width: 0; }
.post-content .table-wide table { min-width: 640px; }
.post-table-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
