/* ===================================================================
   sdp4n6.dev v4 — Redesigned Theme
   Professional, sleek, modern with subtle cyber undertones.
   =================================================================== */

:root {
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  /* Night palette — muted dark with restrained accent */
  --bg: #0a0a0f;
  --bg-soft: #101018;
  --surface: rgba(18, 18, 28, 0.75);
  --surface-strong: #161622;
  --surface-muted: rgba(22, 22, 34, 0.92);
  --text: #b8bcc8;
  --text-strong: #e8eaf0;
  --text-dim: #6b7084;
  --border: rgba(107, 112, 132, 0.18);
  --border-strong: rgba(107, 112, 132, 0.32);
  --accent: #64dfda;
  --accent-dim: rgba(100, 223, 218, 0.12);
  --accent-strong: #80ffe8;
  --accent-warm: #e8a87c;
  --danger: #ef6f6f;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.35);

  --container: 1120px;
  --header-h: 56px;
}

html[data-theme="day"] {
  --bg: #f5f6f8;
  --bg-soft: #ebedf2;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --surface-muted: rgba(250, 250, 252, 0.95);
  --text: #2d3142;
  --text-strong: #1a1d2e;
  --text-dim: #6b7084;
  --border: rgba(45, 49, 66, 0.12);
  --border-strong: rgba(45, 49, 66, 0.22);
  --accent: #0d9488;
  --accent-dim: rgba(13, 148, 136, 0.08);
  --accent-strong: #0f766e;
  --accent-warm: #b45309;
  --danger: #b91c1c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.1);
}

/* === RESET === */

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

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

::selection {
  background: rgba(100, 223, 218, 0.2);
}

a {
  color: var(--text-strong);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent);
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

p,
h1,
h2,
h3,
h4 {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--text-strong);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.6rem);
  font-weight: 700;
}

h2 {
  font-size: clamp(1.15rem, 1.8vw, 1.5rem);
  font-weight: 600;
}

h3 {
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  font-weight: 600;
}

code,
pre,
kbd {
  font-family: var(--font-mono);
}

/* === LAYOUT === */

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus-visible {
  left: 14px;
  top: 14px;
  width: auto;
  height: auto;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  z-index: 300;
}

.container {
  width: min(var(--container), calc(100% - 2rem));
  margin: 0 auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === READING PROGRESS === */

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  z-index: 300;
  background: transparent;
}

.reading-progress::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--accent);
  transition: width 0.1s linear;
}

/* === HEADER === */

.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px) saturate(1.2);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}

.brand-mark .accent {
  color: var(--accent);
}

.site-nav {
  display: flex;
  align-items: center;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.84rem;
  font-weight: 500;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-links a:hover {
  color: var(--text-strong);
  background: var(--accent-dim);
}

.nav-links a.is-active {
  color: var(--accent);
  background: var(--accent-dim);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.theme-toggle,
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover,
.nav-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text-strong);
}

.theme-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.nav-toggle {
  display: none;
}

.nav-toggle-icon {
  width: 16px;
  display: grid;
  gap: 3px;
}

.nav-toggle-icon span {
  display: block;
  width: 100%;
  height: 1.5px;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle.is-open .nav-toggle-icon span:nth-child(1) {
  transform: translateY(4.5px) rotate(45deg);
}

.nav-toggle.is-open .nav-toggle-icon span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.is-open .nav-toggle-icon span:nth-child(3) {
  transform: translateY(-4.5px) rotate(-45deg);
}

/* === BUTTONS === */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-weight: 500;
  font-size: 0.88rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.btn.primary:hover {
  background: rgba(100, 223, 218, 0.18);
  color: var(--accent-strong);
}

.btn.ghost {
  color: var(--text-dim);
}

.btn.ghost:hover {
  color: var(--text-strong);
  border-color: var(--border-strong);
}

.btn.small {
  min-height: 32px;
  padding: 0 0.7rem;
  font-size: 0.8rem;
}

/* === HERO === */

.hero {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
  padding: 2rem 0 1rem;
}

.hero-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.terminal-prompt {
  opacity: 0.6;
}

.hero h1 {
  line-height: 1.15;
}

.hero-lead {
  max-width: 52ch;
  color: var(--text-dim);
  font-size: 1.05rem;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.hero-aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.8rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.stat-num {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-strong);
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.connect-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 1rem;
}

.connect-card h2 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.social-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.social-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  padding: 0 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  color: var(--text);
  transition: all 0.15s ease;
}

.social-list a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.social-list a svg {
  opacity: 0.4;
  transition: opacity 0.15s ease;
}

.social-list a:hover svg {
  opacity: 1;
}

/* === SECTION GRID === */

.section-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  margin-bottom: 2.5rem;
}

.section-tile {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-decoration: none;
  transition: all 0.15s ease;
}

.section-tile:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent);
  flex-shrink: 0;
}

.tile-text {
  flex: 1;
  min-width: 0;
}

.tile-text h2 {
  font-size: 1rem;
  margin-bottom: 0.15rem;
}

.tile-text p {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.tile-count {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* === SECTIONS / HEADERS === */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.view-all {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-dim);
  font-size: 0.84rem;
  font-weight: 500;
}

.view-all:hover {
  color: var(--accent);
}

/* === FEATURED CARD === */

.featured-block {
  margin-bottom: 2.5rem;
}

.feature-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  border-left: 3px solid var(--accent);
}

.feature-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.section-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 0.5rem;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meta-sep::before {
  content: "·";
  margin-right: 0.1rem;
}

.feature-card h3 a {
  color: var(--text-strong);
}

.feature-card h3 a:hover {
  color: var(--accent);
}

.summary {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.6;
}

/* === POST GRID & CARDS === */

.post-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: all 0.15s ease;
}

.post-card:hover {
  border-color: var(--border-strong);
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.post-card h2,
.post-card h3 {
  font-size: 1.05rem;
}

.post-card h2 a,
.post-card h3 a {
  color: var(--text-strong);
}

.post-card h2 a:hover,
.post-card h3 a:hover {
  color: var(--accent);
}

.read-time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: auto;
}

/* === LATEST FEED === */

.latest-feed {
  margin-bottom: 2.5rem;
}

/* === TAGS === */

.tags-line,
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  height: 24px;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  text-decoration: none;
  transition: all 0.15s ease;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tag .count {
  opacity: 0.5;
}

/* === PAGE HERO === */

.page-hero {
  padding: 1.5rem 0 1rem;
  margin-bottom: 1.5rem;
}

.page-hero-inner {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.page-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.intro-copy {
  max-width: 60ch;
  color: var(--text-dim);
}

/* === SEARCH === */

.search-shell {
  margin-bottom: 1.5rem;
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-dim);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 2.5rem 0 2.5rem;
  font-size: 0.9rem;
}

.search-input::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

.search-input:focus {
  border-color: var(--accent);
}

.search-kbd {
  position: absolute;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  pointer-events: none;
}

.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-strong);
}

.filter-chip.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.search-meta {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.search-meta kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 0.68rem;
  vertical-align: middle;
}

.search-results {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.search-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s ease;
}

.search-item:hover {
  border-color: var(--border-strong);
}

.search-empty {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* === CONTENT LAYOUT === */

.content-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.sidebar-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 1rem;
}

.sidebar-heading {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.6rem;
}

.sidebar-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.sidebar-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text);
  transition: all 0.15s ease;
}

.sidebar-links a:hover {
  background: var(--accent-dim);
  color: var(--text-strong);
}

.sidebar-links .count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.empty-state {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 2rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--text-dim);
}

/* === ARTICLE === */

.article-shell {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.article-header {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}

.breadcrumbs {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.breadcrumbs a {
  color: var(--text-dim);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.breadcrumbs svg {
  opacity: 0.4;
}

.article-title-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.article-lead {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 68ch;
  line-height: 1.6;
}

.article-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.article-meta-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
}

.meta-dot::before {
  content: "·";
}

.article-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

/* === PROSE === */

.prose {
  max-width: 72ch;
}

.article-body {
  color: var(--text);
}

.article-shell,
.article-header,
.article-layout,
.article-body,
.prose,
.prose > * {
  min-width: 0;
}

.prose h2,
.prose h3,
.prose h4 {
  margin-top: 2rem;
  margin-bottom: 0.7rem;
  scroll-margin-top: calc(var(--header-h) + 24px);
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose table,
.prose pre {
  margin: 0 0 1rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.prose ul,
.prose ol {
  padding-left: 1.3rem;
}

.prose li + li {
  margin-top: 0.35rem;
}

.prose blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1rem;
  color: var(--text-dim);
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(100, 223, 218, 0.3);
  text-underline-offset: 2px;
}

.prose a:hover {
  text-decoration-color: var(--accent);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  font-size: 0.9rem;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.prose th {
  background: var(--surface);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.82rem;
}

.prose code {
  font-size: 0.88em;
}

.prose p code,
.prose li code,
.prose td code {
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.prose pre {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  background: var(--surface-strong);
  font-size: 0.86rem;
  line-height: 1.6;
}

.code-wrap {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}

.copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.article-figure {
  margin: 1.2rem 0;
}

.article-figure figcaption {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* === TOC === */

.toc-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 1rem;
  align-self: start;
}

.toc-card h2 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.toc-card nav ul {
  margin: 0;
  padding-left: 0.9rem;
  display: grid;
  gap: 0.25rem;
}

.toc-card a {
  color: var(--text-dim);
  font-size: 0.82rem;
  transition: color 0.15s ease;
}

.toc-card a:hover,
.toc-card a.is-current {
  color: var(--accent);
}

/* === RELATED NAV === */

.related-nav {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.related-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

.related-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.15s ease;
}

.related-card:hover {
  border-color: var(--accent);
}

.related-direction {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.related-card h3 {
  font-size: 0.95rem;
  color: var(--text-strong);
}

.related-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* === FOOTER === */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

.footer-inner {
  padding: 2rem 0;
}

.footer-top {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.footer-logo {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-strong);
}

.footer-logo .accent {
  color: var(--accent);
}

.footer-copy {
  margin-top: 0.4rem;
  font-size: 0.84rem;
  color: var(--text-dim);
  max-width: 38ch;
}

.footer-nav {
  display: flex;
  gap: 3rem;
}

.footer-col h3 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.footer-col a {
  font-size: 0.84rem;
  color: var(--text);
}

.footer-col a:hover {
  color: var(--accent);
}

.footer-bottom {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.footer-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* === ANIMATIONS === */

[data-reveal] {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

[data-reveal="delayed"] {
  transform: translateY(10px);
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .post-card,
  .related-card,
  .section-tile {
    transition: none;
  }
}

/* === RESPONSIVE === */

@media (max-width: 760px) {
  .container {
    width: calc(100% - 1.25rem);
  }

  .nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    display: none;
  }

  .site-nav.open {
    display: block;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 199;
  }

  .site-nav.open .nav-links {
    flex-direction: column;
    padding: 0.5rem 1rem 0.8rem;
  }

  .site-nav.open .nav-links a {
    height: 42px;
    justify-content: center;
  }

  .hero {
    padding: 1.5rem 0 0.5rem;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-top {
    flex-direction: column;
    gap: 1.5rem;
  }

  .article-meta-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .prose pre,
  .prose .highlight pre {
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    padding-right: 2rem;
  }

  .prose pre code,
  .prose .highlight code,
  .prose .highlight span {
    white-space: inherit !important;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .prose table {
    table-layout: fixed;
  }

  .breadcrumbs,
  .article-lead {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

@media (min-width: 761px) {
  .hero {
    grid-template-columns: 1.4fr 1fr;
    align-items: start;
    gap: 2.5rem;
    padding: 3rem 0 2rem;
  }

  .section-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .post-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .content-layout {
    grid-template-columns: 1fr 260px;
    align-items: start;
  }

  .sidebar {
    position: sticky;
    top: calc(var(--header-h) + 16px);
  }

  .related-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1080px) {
  .post-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .article-layout.with-sidebar {
    grid-template-columns: 1fr 260px;
    align-items: start;
    gap: 2rem;
  }

  .toc-card {
    position: sticky;
    top: calc(var(--header-h) + 16px);
  }
}
