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

:root {
  --bg: #0d0d0f;
  --surface: rgba(13, 13, 15, 0.9);
  --border: #252530;
  --accent: #5b8fff;
  --purple: #a78bff;
  --muted: #6b7280;
  --text: #c9d1d9;
  --text-bright: #e2e8f0;
  --divider: 0.5px solid #1e1e22;
  --font: 'JetBrains Mono', monospace;
}

html {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- HEADER ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: var(--divider);
  padding: 1.25rem 0;
  margin-bottom: 3rem;
}

.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-logo {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-bright);
  text-decoration: none;
}
.site-logo:hover { color: var(--accent); text-decoration: none; }

.nav-right {
  display: flex;
  gap: 1.5rem;
  font-size: 0.78rem;
}
.nav-right a { color: var(--muted); text-decoration: none; }
.nav-right a:hover { color: var(--text-bright); text-decoration: none; }

/* ---- MAIN ---- */
.site-main { flex: 1; padding-bottom: 3rem; }

/* ---- FOOTER ---- */
.site-footer {
  display: flex;
  justify-content: space-between;
  padding: 2rem 0;
  border-top: var(--divider);
  margin-top: 4rem;
  font-size: 0.72rem;
  color: var(--muted);
}

/* ---- SECTION LABEL ---- */
.section-label {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 0.5px;
  background: #1e1e22;
}

/* ---- PAGE HEADER ---- */
.page-header { margin-bottom: 0.5rem; }
.cve-header { margin-top: 2.5rem; }

/* ---- POST LIST ---- */
.post-list { list-style: none; }

.post-list-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 1.25rem;
  padding: 0.55rem 0;
  border-bottom: var(--divider);
}

.post-date {
  color: var(--muted);
  flex-shrink: 0;
  font-size: 0.75rem;
  width: 6.5rem;
}

.post-list-row .post-title {
  color: var(--text);
  font-size: 0.85rem;
  flex: 1;
  min-width: 12rem;
  text-decoration: none;
}
.post-list-row .post-title:hover { color: var(--accent); text-decoration: none; }

.post-list-viewall {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
}
.post-list-viewall:hover { text-decoration: underline; }

/* ---- PAGINATION ---- */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: var(--divider);
  font-size: 0.75rem;
}
.pagination-link { color: var(--accent); text-decoration: none; }
.pagination-link:hover { text-decoration: underline; }
.pagination-disabled { color: var(--muted); opacity: 0.4; }
.pagination-pages { color: var(--muted); }

/* ---- TAGS ---- */
.post-tags { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
.tag {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  background: #13131a;
  white-space: nowrap;
  text-decoration: none;
}
a.tag:hover {
  color: var(--text-bright);
  border-color: #3a3a4a;
  text-decoration: none;
}

.tag-main {
  color: var(--accent);
  border-color: rgba(91, 143, 255, 0.35);
  background: rgba(91, 143, 255, 0.07);
}

/* ---- TAGS INDEX PAGE ---- */
.tags-index {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.tag-index-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
}
.tag-index-item:hover .tag {
  color: var(--text-bright);
  border-color: #3a3a4a;
  text-decoration: none;
}

.tag-count {
  font-size: 0.6rem;
  color: var(--muted);
  opacity: 0.7;
}

/* ---- POST LAYOUT ---- */
.post-layout {
  display: flex;
  gap: 3rem;
  align-items: flex-start;
}

.post-content { flex: 1; min-width: 0; overflow: hidden; }

/* ---- POST HEADER ---- */
.post-header { margin-bottom: 2rem; padding-bottom: 1.25rem; border-bottom: var(--divider); }

.post-title-h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.25;
  margin-bottom: 0.6rem;
}

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

.post-description {
  font-size: 0.82rem;
  color: var(--muted);
  border-left: 2px solid var(--border);
  padding-left: 0.75rem;
  margin-top: 0.75rem;
  font-style: italic;
}

/* ---- POST BODY ---- */
.post-body h2,
.post-body h3,
.post-body h4 {
  color: var(--text-bright);
  margin: 1.75rem 0 0.75rem;
  font-weight: 600;
  line-height: 1.3;
}
.post-body h2 {
  font-size: 1.05rem;
  border-bottom: var(--divider);
  padding-bottom: 0.3rem;
}
.post-body h3 { font-size: 0.93rem; }
.post-body h4 { font-size: 0.83rem; color: var(--muted); }

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

.post-body ul,
.post-body ol {
  margin: 0.5rem 0 1rem;
  padding-left: 2rem;
}
.post-body li { margin-bottom: 0.25rem; }

.post-body a { color: var(--accent); }
.post-body a:hover { text-decoration: underline; }

.post-body strong { color: var(--text-bright); font-weight: 600; }
.post-body em { color: var(--purple); font-style: italic; }

.post-body hr {
  border: none;
  border-top: var(--divider);
  margin: 2rem 0;
}

/* inline code */
.post-body code {
  font-family: var(--font);
  font-size: 0.82em;
  background: #13131a;
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  color: var(--purple);
}

.post-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.post-body blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.4rem 1rem;
  margin: 1rem 0;
  color: var(--muted);
  font-style: italic;
}

/* ---- TABLES ---- */
.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin: 1rem 0;
}

.post-body th,
.post-body td {
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-bottom: var(--divider);
}

.post-body th {
  color: var(--text-bright);
  font-weight: 600;
  border-bottom: 0.5px solid #252530;
}

.post-body td {
  color: var(--muted);
}

.post-body tr:last-child td {
  border-bottom: none;
}

/* ---- IMAGES ---- */
.post-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem 0;
}

/* ---- CODE BLOCKS (Chroma) ---- */
.highlight {
  border-radius: 4px;
  border: 1px solid var(--border);
  margin: 1rem 0;
  overflow: hidden;
}

.highlight pre {
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.65;
  margin: 0;
}

/* ---- TOC SIDEBAR ---- */
.toc-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 5rem;
  font-size: 0.72rem;
  color: var(--muted);
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
}

.toc-label {
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
  display: block;
}

.toc nav ul {
  list-style: none;
  padding: 0;
}

.toc nav ul ul {
  padding-left: 0.85rem;
  margin-top: 0.15rem;
}

.toc nav li { margin-bottom: 0.3rem; }

.toc nav a {
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
  display: block;
  transition: color 0.15s;
}
.toc nav a:hover { color: var(--accent); }
.toc nav a.active { color: var(--accent); }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .post-layout { flex-direction: column-reverse; }
  .toc-sidebar { width: 100%; position: static; }

  .post-body table { display: block; overflow-x: auto; white-space: nowrap; }
  .post-list-row { flex-wrap: wrap; }
  .post-date { width: auto; }
}
