/* Gavyn Blog — Modern Editorial Academic & Engineering Theme */
:root {
  --bg: #faf9f6;
  --bg-elevated: #ffffff;
  --bg-subtle: #f2f1ec;
  --bg-glass: rgba(250, 249, 246, 0.82);
  --text: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.09);
  --code-bg: #f4f4f5;
  --code-block-bg: #16181d;
  --code-block-text: #e4e4e7;
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-md: 0 8px 24px -8px rgba(24, 24, 27, 0.08), 0 2px 6px rgba(24, 24, 27, 0.03);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #0c0f14;
  --bg-elevated: #131822;
  --bg-subtle: #1a2130;
  --bg-glass: rgba(12, 15, 20, 0.82);
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.085);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.13);
  --code-bg: rgba(255, 255, 255, 0.075);
  --code-block-bg: #090c10;
  --code-block-text: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 10px 28px -8px rgba(0, 0, 0, 0.48);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.16s ease, opacity 0.16s ease;
}

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

/* Reading Progress Bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2.5px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  z-index: 120;
  transition: width 0.08s linear;
  pointer-events: none;
}

/* Sticky Navbar */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand:hover {
  color: var(--text);
  opacity: 0.88;
}

.brand-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--border-strong);
}

.brand-domain {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background-color 0.16s ease, color 0.16s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-subtle);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 6px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-toggle {
  display: none;
}

/* Mobile Nav Drawer */
.mobile-nav {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 12px 20px 18px;
}

.mobile-nav.open {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-nav .nav-link {
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}

/* Main Containers */
.page-main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 72px;
}

.page-narrow {
  max-width: 820px;
}

/* Hero Card */
.hero {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 34px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #6366f1 55%, #06b6d4);
  opacity: 0.85;
}

.hero-left {
  display: flex;
  align-items: center;
  gap: 22px;
}

.hero-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.hero-title {
  margin: 0 0 6px;
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.hero-bio {
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 0.96rem;
  max-width: 520px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-chip {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 550;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  transition: all 0.16s ease;
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

/* Filter & Search Bar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-pill {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

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

.filter-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.search-box {
  position: relative;
  min-width: 220px;
  flex: 0 1 260px;
}

.search-box input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Post Cards */
.post-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.post-card {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 26px;
  box-shadow: var(--shadow-sm);
  color: inherit;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.post-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  color: inherit;
}

.post-card.hidden {
  display: none;
}

.post-card-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.post-card-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.015em;
  color: var(--text);
}

.post-card:hover .post-card-title {
  color: var(--accent);
}

.post-card-excerpt {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 0.93rem;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.76rem;
  font-weight: 550;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 999px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  display: none;
}

/* Article 2-Column Layout */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 44px;
  align-items: start;
}

.article-layout.no-toc {
  grid-template-columns: minmax(0, 780px);
  justify-content: center;
}

.article-shell {
  min-width: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 42px 44px;
  box-shadow: var(--shadow-sm);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.back-link:hover {
  color: var(--accent);
}

.article-header {
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.article-title {
  margin: 0 0 14px;
  font-size: clamp(1.55rem, 2.8vw, 2.15rem);
  font-weight: 780;
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 0.86rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Mobile TOC */
.mobile-toc {
  display: none;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  padding: 10px 14px;
}

.mobile-toc summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.mobile-toc ul {
  list-style: none;
  padding: 10px 0 2px;
  margin: 0;
  font-size: 0.86rem;
}

/* Desktop Sticky TOC */
.toc-aside {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.toc-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.toc-item a {
  display: block;
  font-size: 0.83rem;
  line-height: 1.45;
  color: var(--text-muted);
  padding: 2px 0;
  transition: color 0.15s ease;
}

.toc-item a:hover,
.toc-item a.active {
  color: var(--accent);
  font-weight: 600;
}

.toc-item.level-3 { padding-left: 12px; }
.toc-item.level-4 { padding-left: 22px; }

/* Article Prose */
.prose {
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text);
  overflow-wrap: break-word;
}

.prose > :first-child { margin-top: 0; }

.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--text);
  font-weight: 720;
  letter-spacing: -0.02em;
  line-height: 1.35;
  scroll-margin-top: 84px;
}

.prose h2 {
  font-size: 1.42rem;
  margin: 2.2rem 0 0.9rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.prose h3 {
  font-size: 1.2rem;
  margin: 1.7rem 0 0.7rem;
}

.prose h4 {
  font-size: 1.05rem;
  margin: 1.3rem 0 0.55rem;
}

.prose p {
  margin: 0 0 1.15rem;
}

.prose ul, .prose ol {
  margin: 0 0 1.2rem;
  padding-left: 1.55rem;
}

.prose li {
  margin-bottom: 0.38rem;
}

.prose li > p {
  margin-bottom: 0.45rem;
}

.prose blockquote {
  margin: 1.3rem 0;
  padding: 12px 18px;
  border-left: 3.5px solid var(--accent);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

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

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

/* Code */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 5px;
}

.prose pre, .prose figure.highlight {
  margin: 1.3rem 0;
  background: var(--code-block-bg);
  color: var(--code-block-text);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.prose pre code, .prose figure.highlight code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.prose figure.highlight table {
  border: 0;
  margin: 0;
  width: auto;
}

.prose figure.highlight td {
  border: 0;
  padding: 0;
}

.prose figure.highlight td.gutter {
  padding-right: 16px;
  color: #64748b;
  user-select: none;
  text-align: right;
}

/* Tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4rem 0;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.prose th {
  background: var(--bg-subtle);
  font-weight: 650;
}

/* Figures & Raster Images */
.prose img:not([src$=".svg"]) {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.35rem auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #ffffff;
  padding: 4px;
  cursor: zoom-in;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.prose img:not([src$=".svg"]):hover {
  box-shadow: var(--shadow-md);
}

/* Inline & Display Math SVGs (from Pandoc/MathJax) */
.prose img[src$=".svg"] {
  display: inline-block;
  vertical-align: middle;
  max-width: 100%;
  height: auto;
  margin: 0 2px;
  border: 0;
  box-shadow: none;
  background: transparent;
  cursor: default;
}

.prose figure {
  margin: 1.35rem 0;
  text-align: center;
  overflow-x: auto;
}

.prose figure img[src$=".svg"] {
  display: block;
  margin: 0.4rem auto;
}

.prose figcaption {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

[data-theme="dark"] .prose img[src$=".svg"] {
  filter: invert(0.92) hue-rotate(180deg);
}

/* KaTeX Overflow Handling */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 2px;
  margin: 1.15rem 0;
}

/* Prev / Next Navigation */
.post-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.post-nav-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: inherit;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.post-nav-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  color: inherit;
}

.post-nav-card.next {
  text-align: right;
}

.post-nav-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.post-nav-title {
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--text);
}

/* Archives Timeline */
.section-head {
  margin-bottom: 28px;
}

.section-head h1 {
  margin: 0 0 6px;
  font-size: 1.85rem;
  font-weight: 780;
  letter-spacing: -0.03em;
}

.section-head p {
  margin: 0;
  color: var(--text-secondary);
}

.year-group {
  margin-bottom: 32px;
}

.year-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 1.25rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.year-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 2px 9px;
  border-radius: 999px;
}

.timeline-list {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.timeline-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background-color 0.14s ease;
}

.timeline-row:last-child {
  border-bottom: 0;
}

.timeline-row:hover {
  background: var(--bg-subtle);
  color: var(--accent);
}

.timeline-title {
  font-weight: 600;
  font-size: 0.97rem;
}

.timeline-date {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* Tags Grid */
.tags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.tag-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-weight: 650;
  box-shadow: var(--shadow-sm);
  transition: all 0.16s ease;
}

.tag-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tag-card-count {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* About Services Grid */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.service-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.service-tile:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  color: var(--text);
}

.service-tile strong {
  font-size: 0.94rem;
}

.service-tile span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(9, 12, 18, 0.86);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: min(94vw, 1200px);
  max-height: 90vh;
  border-radius: var(--radius-sm);
  background: #ffffff;
  padding: 6px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* Back to Top */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  box-shadow: var(--shadow-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.15s ease;
  z-index: 90;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  color: var(--accent);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-links a {
  color: var(--text-muted);
}

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

/* Error Page */
.error-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.error-card {
  max-width: 480px;
  width: 100%;
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 32px;
  box-shadow: var(--shadow-md);
}

.error-code {
  font-size: 4.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 0 0 12px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.error-card h1 {
  margin: 0 0 10px;
  font-size: 1.3rem;
}

.error-card p {
  margin: 0 0 24px;
  color: var(--text-secondary);
  font-size: 0.94rem;
}

/* Responsive */
@media (max-width: 1024px) {
  .article-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .toc-aside {
    display: none;
  }
  .mobile-toc {
    display: block;
  }
}

@media (max-width: 768px) {
  .nav-inner {
    padding: 0 16px;
  }
  .nav-links {
    display: none;
  }
  .mobile-toggle {
    display: inline-flex;
  }
  .brand-domain {
    display: none;
  }
  .page-main {
    padding: 24px 16px 56px;
  }
  .hero {
    flex-direction: column;
    align-items: flex-start;
    padding: 24px 20px;
  }
  .hero-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .article-shell {
    padding: 22px 18px 28px;
    border-radius: var(--radius-md);
  }
  .post-card {
    padding: 18px 18px;
  }
  .post-nav {
    grid-template-columns: 1fr;
  }
  .post-nav-card.next {
    text-align: left;
  }
  .timeline-row {
    flex-direction: column;
    gap: 4px;
  }
  .footer-inner {
    justify-content: center;
  }
}
