:root {
  --bg: #f2eee6;
  --bg-soft: rgba(255, 252, 245, 0.78);
  --text: #201a16;
  --muted: #776b61;
  --card: rgba(255, 252, 245, 0.84);
  --border: rgba(63, 45, 34, 0.14);
  --primary: #2f6df6;
  --primary-dark: #214db6;
  --accent: #e85d75;
  --gold: #c58a2a;
  --danger: #c2410c;
  --shadow: 0 24px 80px rgba(63, 45, 34, 0.16);
  --radius: 28px;
  --display: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  --body: "Noto Serif SC", "Source Han Serif SC", "LXGW WenKai", "霞鹜文楷", "Songti SC", serif;
  --ui: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

[data-theme="dark"] {
  --bg: #11100f;
  --bg-soft: rgba(24, 22, 21, 0.78);
  --text: #f8f1e8;
  --muted: #b8aa9b;
  --card: rgba(28, 25, 23, 0.82);
  --border: rgba(255, 244, 229, 0.13);
  --primary: #8fb6ff;
  --primary-dark: #c6d9ff;
  --accent: #ff8da1;
  --gold: #f1c376;
  --danger: #fb923c;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
html {
  overflow-x: clip;
  scroll-behavior: smooth;
  scroll-padding-top: 104px;
  -webkit-text-size-adjust: 100%;
}
body {
  min-width: 320px;
  margin: 0;
  overflow-x: clip;
  color: var(--text);
  font-family: var(--body);
  background: var(--bg);
  font-weight: 500;
  line-height: 1.82;
  letter-spacing: 0.01em;
  transition: color 0.2s ease, background 0.2s ease;
}
body::selection { background: rgba(232, 93, 117, 0.28); }
a { color: inherit; text-decoration: none; }
a, button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }
button, input, textarea { font: inherit; }
.nav, .btn, .post-meta, .eyebrow, .section-heading span, input, textarea, .flash, .pill { font-family: var(--ui); }
:where(a, button, input, textarea, select, [tabindex]):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 72%, #fff);
  outline-offset: 3px;
}
code {
  padding: 0.18rem 0.42rem;
  border-radius: 9px;
  color: var(--primary-dark);
  background: rgba(47, 109, 246, 0.12);
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 12%, rgba(232, 93, 117, 0.18), transparent 26rem),
    radial-gradient(circle at 86% 6%, rgba(47, 109, 246, 0.2), transparent 28rem),
    radial-gradient(circle at 58% 96%, rgba(197, 138, 42, 0.16), transparent 26rem),
    linear-gradient(135deg, rgba(255,255,255,0.38), transparent 35%),
    var(--bg);
}
.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(63, 45, 34, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(63, 45, 34, 0.1) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at center, black, transparent 72%);
}

.topbar {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  z-index: 20;
  display: flex;
  width: min(1180px, calc(100% - 32px));
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  box-shadow: 0 16px 48px rgba(31, 23, 18, 0.12);
  backdrop-filter: blur(22px) saturate(1.3);
  transform: translateX(-50%);
  transition: transform 0.25s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.topbar.is-hidden { transform: translate(-50%, -92px); }
.brand {
  position: relative;
  padding: 0 12px;
  font-family: var(--display);
  font-size: 1.22rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.brand::before {
  content: "✦";
  margin-right: 8px;
  color: var(--gold);
}
.nav { display: flex; align-items: center; gap: 6px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.nav a, .theme-toggle, .menu-toggle {
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 8px 12px;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.nav a:hover, .nav a.is-active, .theme-toggle:hover, .menu-toggle:hover {
  color: var(--text);
  background: rgba(197, 138, 42, 0.13);
  transform: translateY(-1px);
}
.nav a.is-active { color: var(--primary-dark); }
.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  place-items: center;
  gap: 4px;
  padding: 10px;
}
.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.topbar.is-menu-open .menu-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.topbar.is-menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
.topbar.is-menu-open .menu-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.menu-scrim {
  position: fixed;
  inset: 0;
  z-index: 19;
  visibility: hidden;
  border: 0;
  background: rgba(17, 16, 15, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  backdrop-filter: blur(3px);
}

.flash-stack {
  position: fixed;
  top: 88px;
  right: 20px;
  z-index: 30;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100% - 40px));
}
.flash {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  backdrop-filter: blur(18px);
}
.flash.success { border-color: rgba(22, 163, 74, 0.3); }
.flash.error { border-color: rgba(220, 38, 38, 0.32); }

.hero {
  position: relative;
  display: grid;
  min-height: 680px;
  place-items: center;
  padding: 140px 20px 90px;
  color: #fff;
  overflow: hidden;
  background: linear-gradient(135deg, #172554, #111827);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(15, 18, 36, 0.62), rgba(74, 36, 99, 0.34)),
    var(--cover-image, url('/blog/static/img/hero.svg')) var(--cover-x, 50%) var(--cover-y, 50%) / cover no-repeat;
  transform: scale(var(--cover-zoom, 1));
  transform-origin: var(--cover-x, 50%) var(--cover-y, 50%);
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  height: 90px;
  background: linear-gradient(transparent, var(--bg));
}
.hero-cover-image,
.post-hero-cover-image { display: none; }
.hero-inner, .post-hero-inner {
  position: relative;
  z-index: 2;
  width: min(900px, 100%);
  text-align: center;
}
.eyebrow, .section-heading span {
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.hero .eyebrow { color: #ffe1a8; }
.hero h1, .post-hero h1, .section-heading h1, .section-heading h2, .about-card h1, .not-found h1, .auth-card h1, .admin-header h1, .editor-header h1 {
  font-family: var(--display);
  font-weight: 900;
}
.hero h1 {
  margin: 14px 0;
  font-size: clamp(2.8rem, 8vw, 6.2rem);
  font-weight: 900;
  line-height: 0.94;
  letter-spacing: -0.03em;
  text-shadow: 0 20px 65px rgba(0,0,0,0.4);
}
.hero p {
  margin: 0 auto;
  max-width: 680px;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(1rem, 2vw, 1.28rem);
}
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 32px; }

.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  padding: 0 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  box-shadow: 0 16px 40px rgba(232, 93, 117, 0.28);
}
.btn.ghost {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.12);
}
.btn.soft {
  color: var(--text);
  background: rgba(197, 138, 42, 0.13);
}
.btn.danger {
  color: #fff;
  background: linear-gradient(135deg, var(--danger), var(--accent));
}

.layout {
  display: grid;
  width: min(1360px, calc(100% - 18px));
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 40px;
  margin: 28px auto 88px;
  align-items: start;
}
.layout.single-column { grid-template-columns: minmax(0, 920px); justify-content: center; margin-top: 120px; }
.layout.subpage { margin-top: 132px; }
.layout.home-layout .content-panel { transform: translateX(calc((min(1360px, calc(100vw - 18px)) - 100vw) / 4 - 3px)); }
.layout.home-layout .post-showcase-grid { gap: 32px; }
.layout.home-layout .showcase-card:nth-child(even) { transform: translateX(56px); }
.layout.home-layout .showcase-card:nth-child(even):hover { transform: translateX(56px) translateY(-6px); }
.layout.admin-shell, .layout.editor-shell { grid-template-columns: minmax(0, 1080px); }
.layout.post-layout {
  width: min(1360px, calc(100% - 18px));
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 40px;
  margin-top: clamp(7px, 1vw, 14px);
}
.content-panel, .sidebar { min-width: 0; }
.sidebar { position: sticky; top: 104px; display: grid; gap: 18px; transform: translateX(34px); }
.post-layout .sidebar { top: 132px; }
.glass-card, .post-card, .term-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.15);
}

.section-heading { margin: 0 0 20px; padding: 30px 6px 0; }
.section-heading.compact { padding-top: 0; }
.section-heading.inline { padding: 0; margin: 0 0 20px; }
.section-heading h1, .section-heading h2 {
  margin: 4px 0 0;
  font-size: clamp(2.15rem, 4vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
}

.post-grid { display: grid; gap: 24px; }
.post-card {
  position: relative;
  display: grid;
  grid-template-columns: 255px minmax(0, 1fr);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.post-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(var(--accent), var(--gold));
  opacity: 0;
  transition: opacity 0.2s ease;
}
.post-card:hover { transform: translateY(-5px) rotate(-0.15deg); }
.post-card:hover::before { opacity: 1; }
.post-card.small { grid-template-columns: 190px minmax(0, 1fr); }
.post-cover { min-height: 218px; background-position: center; background-size: cover; transition: transform 0.4s ease; }
.post-card:hover .post-cover { transform: scale(1.035); }
.gradient-0 { background: linear-gradient(135deg, #2947a9, #e85d75); }
.gradient-1 { background: linear-gradient(135deg, #0f766e, #2f6df6); }
.gradient-2 { background: linear-gradient(135deg, #c58a2a, #e85d75); }
.gradient-3 { background: linear-gradient(135deg, #5b4bd8, #38bdf8); }
.gradient-4 { background: linear-gradient(135deg, #15803d, #facc15); }
.post-body { padding: 25px; }
.post-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 0.83rem; font-weight: 800; }
.post-meta.light { justify-content: center; color: rgba(255, 255, 255, 0.84); }
.post-body h2 { margin: 10px 0 8px; font-size: clamp(1.45rem, 3vw, 2.08rem); line-height: 1.2; }
.post-body h2 a:hover { color: var(--accent); }
.post-body p { margin: 0; color: var(--muted); }
.post-tags, .article-tags, .tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.post-tags a, .post-tags span, .article-tags a, .tag-cloud a, .pill {
  border-radius: 999px;
  color: var(--primary-dark);
  background: rgba(47, 109, 246, 0.11);
  font-size: 0.84rem;
  font-weight: 800;
  padding: 5px 10px;
}

.post-showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
}
.showcase-card {
  position: relative;
  aspect-ratio: 141 / 100;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 30px;
  box-shadow: var(--shadow);
  isolation: isolate;
  transition: transform 0.32s ease, box-shadow 0.32s ease, filter 0.32s ease;
}
.showcase-card.small { min-height: 300px; }
.showcase-card[style*="--cover-image"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cover-image) var(--cover-x, 50%) var(--cover-y, 50%) / cover no-repeat;
  transform: scale(var(--cover-zoom, 1));
  transform-origin: var(--cover-x, 50%) var(--cover-y, 50%);
  z-index: -2;
}
.showcase-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 10%, rgba(232, 93, 117, 0.08), transparent 44%),
    linear-gradient(180deg, rgba(9, 7, 6, 0.04) 22%, rgba(9, 7, 6, 0.22) 54%, rgba(9, 7, 6, 0.82) 100%);
  z-index: -1;
}
.showcase-card:hover { transform: translateY(-6px); filter: saturate(1.08); }
.showcase-link { position: absolute; inset: 0; z-index: 2; }
.showcase-overlay {
  position: absolute;
  inset: auto 22px 22px;
  display: grid;
  gap: 10px;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.72);
  z-index: 1;
}
.showcase-overlay h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.7rem, 3vw, 2.45rem);
  font-weight: 900;
  line-height: 1.08;
}
.showcase-overlay p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: rgba(255, 255, 255, 0.88);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.showcase-overlay .post-tags { margin-top: 0; }
.showcase-overlay .post-tags span {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
}

.profile-card, .side-card { padding: 23px; }
.avatar-wrap {
  position: relative;
  width: fit-content;
}
.github-badge {
  position: absolute;
  right: 2px;
  bottom: 2px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 3px solid var(--card);
  border-radius: 50%;
  color: #fff;
  background: #24292f;
  box-shadow: 0 10px 24px rgba(31, 23, 18, 0.24);
  transition: transform 0.2s ease, background 0.2s ease;
}
.github-badge:hover { background: #111827; transform: translateY(-2px); }
.github-badge svg { width: 24px; height: 24px; fill: currentColor; }
.avatar {
  display: grid;
  width: 148px;
  height: 148px;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  box-shadow: 0 18px 36px rgba(232, 93, 117, 0.26);
  font-family: var(--display);
  font-size: 3.2rem;
  image-rendering: auto;
  object-fit: cover;
  object-position: center 24%;
}
.avatar-image { display: block; }
.profile-avatar-sm,
.profile-avatar-lg {
  display: block;
  border: 3px solid rgba(255, 255, 255, 0.76);
  border-radius: 50%;
  image-rendering: auto;
  object-fit: cover;
  object-position: center 24%;
  box-shadow: 0 16px 36px rgba(31, 23, 18, 0.18);
}
.profile-avatar-sm { width: 96px; height: 96px; }
.profile-avatar-lg { width: 168px; height: 168px; }
.profile-avatar-sm.fallback,
.profile-avatar-lg.fallback {
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  font-family: var(--display);
  font-size: 2.7rem;
}
.profile-avatar-lg.fallback { font-size: 4.5rem; }
.admin-profile-strip { display: flex; align-items: center; gap: 18px; }
.profile-card h2, .side-card h3 { margin: 14px 0 8px; }
.profile-card p, .muted { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.stats span { border-radius: 16px; color: var(--muted); background: rgba(197, 138, 42, 0.11); font-size: 0.78rem; padding: 10px 6px; text-align: center; }
.stats strong { display: block; color: var(--text); font-size: 1.15rem; }
.side-cover-list { display: grid; justify-items: center; gap: 16px; }
.side-cover-card {
  position: relative;
  display: grid;
  width: 92%;
  aspect-ratio: 141 / 100;
  min-height: 138px;
  align-content: end;
  gap: 4px;
  overflow: hidden;
  border-radius: 22px;
  color: #fff;
  padding: 18px 16px;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.72);
  transition: transform 0.25s ease, filter 0.25s ease;
  isolation: isolate;
}
.side-cover-card[style*="--cover-image"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cover-image) var(--cover-x, 50%) var(--cover-y, 50%) / cover no-repeat;
  transform: scale(var(--cover-zoom, 1));
  transform-origin: var(--cover-x, 50%) var(--cover-y, 50%);
  z-index: -2;
}
.side-cover-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(9, 7, 6, 0.04) 24%, rgba(9, 7, 6, 0.2) 56%, rgba(9, 7, 6, 0.8) 100%);
  z-index: -1;
}
.side-cover-card:hover { transform: translateY(-3px); filter: saturate(1.08); }
.side-cover-card span {
  width: fit-content;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  font-family: var(--ui);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
}
.side-cover-card strong { line-height: 1.25; }
.side-cover-card small { color: rgba(255, 255, 255, 0.78); }
.tag-cloud small { color: var(--muted); }

.post-hero {
  position: relative;
  display: grid;
  min-height: clamp(520px, 42vw, 680px);
  place-items: center;
  padding: 132px 20px 84px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  overflow: hidden;
}
.post-hero[style*="--cover-image"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(9, 7, 6, 0.22) 0%, rgba(9, 7, 6, 0.12) 38%, rgba(9, 7, 6, 0.7) 100%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.22), rgba(88, 28, 135, 0.14)),
    var(--cover-image) var(--cover-x, 50%) var(--cover-y, 50%) / cover no-repeat;
  transform: scale(var(--cover-zoom, 1));
  transform-origin: var(--cover-x, 50%) var(--cover-y, 50%);
}
.post-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  height: 62px;
  background: linear-gradient(transparent, var(--bg));
}
.post-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px auto;
}
.post-hero h1 { margin: 0; max-width: 940px; font-size: clamp(2.55rem, 7vw, 5.3rem); line-height: 1; letter-spacing: 0.02em; }
.post-hero p { margin: 0 auto; max-width: 700px; color: rgba(255, 255, 255, 0.86); }
.article, .timeline, .about-card, .not-found, .comments, .auth-card, .admin-header, .admin-post, .editor-header, .upload-card, .editor-form { padding: clamp(24px, 5vw, 42px); }
.article { padding-top: clamp(12px, 2.5vw, 21px); }
.article-content {
  width: min(100%, 780px);
  margin-inline: auto;
  color: var(--text);
  font-size: 1.06rem;
  line-height: 1.9;
}
.article-content h1, .article-content h2, .article-content h3 {
  margin: 2.2em 0 0.75em;
  line-height: 1.25;
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: 0.015em;
}
.article-content h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
.article-content h2 { font-size: clamp(1.55rem, 3vw, 2.05rem); }
.article-content h3 { font-size: clamp(1.25rem, 2.4vw, 1.55rem); }
.article-content > :first-child { margin-top: 0; }
.article-content p { margin: 1.05em 0; }
.article-content ul, .article-content ol { margin: 1.1em 0; padding-left: 1.5em; }
.article-content li + li { margin-top: 0.35em; }
.article-content p, .article-content li { color: color-mix(in srgb, var(--text) 84%, var(--muted)); }
.article-content img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 1.8rem auto;
  border-radius: 20px;
  box-shadow: 0 16px 46px rgba(31, 23, 18, 0.14);
}
.article-content blockquote { margin: 1.8rem 0; border-left: 4px solid var(--accent); border-radius: 14px; background: rgba(232, 93, 117, 0.1); padding: 1rem 1.2rem; }
.article-content blockquote > :first-child { margin-top: 0; }
.article-content blockquote > :last-child { margin-bottom: 0; }
.article-content pre { overflow: auto; margin: 1.7rem 0; border-radius: 20px; background: #111827; padding: 18px; overscroll-behavior-x: contain; }
.article-content pre code { padding: 0; color: #edf2ff; background: transparent; }
.article-content a {
  color: var(--primary-dark);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--primary) 42%, transparent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}
.article-content table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-spacing: 0;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.article-content th,
.article-content td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}
.article-content :where(video, iframe) {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 1.8rem auto;
  border: 0;
  border-radius: 20px;
}

.comments h2 { margin: 4px 0 0; font-family: var(--display); font-weight: 400; font-size: clamp(1.8rem, 3vw, 2.5rem); }
.like-button {
  display: inline-flex;
  min-width: 86px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 1rem;
  font-weight: 900;
}
.like-button:hover { background: linear-gradient(135deg, var(--accent), var(--gold)); }
.like-button span { font-size: 1.2rem; }
.comments { margin-top: 22px; }
.comment-form, .admin-form, .editor-form, .upload-form { display: grid; gap: 16px; }
.comment-form { margin-bottom: 28px; }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 800; }
input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.38);
  padding: 12px 14px;
  outline: 0;
}
[data-theme="dark"] input, [data-theme="dark"] textarea { background: rgba(255, 255, 255, 0.06); }
input:focus, textarea:focus { border-color: rgba(47, 109, 246, 0.45); box-shadow: 0 0 0 4px rgba(47, 109, 246, 0.12); }
.comment-list { display: grid; gap: 14px; }
.comment-item { display: grid; grid-template-columns: 48px 1fr; gap: 14px; border-top: 1px solid var(--border); padding-top: 16px; }
.comment-avatar { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 17px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); font-family: var(--display); }
.comment-item header { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.comment-item p { margin: 6px 0 0; }

.timeline { display: grid; gap: 26px; }
.year-block h2 { margin: 0 0 12px; color: var(--accent); font-size: 2rem; font-family: var(--display); font-weight: 400; }
.timeline-item { display: grid; grid-template-columns: 72px 1fr auto; gap: 16px; align-items: center; border-radius: 16px; padding: 12px 14px; }
.timeline-item:hover { background: rgba(197, 138, 42, 0.12); }
.timeline-item time, .timeline-item small { color: var(--muted); }
.term-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.term-card { display: grid; gap: 6px; padding: 24px; }
.term-card strong { font-size: 1.25rem; }
.term-card span { color: var(--muted); }
.about-card h1, .not-found h1, .auth-card h1, .admin-header h1, .editor-header h1 { margin: 8px 0 12px; font-size: clamp(2.4rem, 6vw, 4.7rem); line-height: 1; }
.about-card h1 { font-size: clamp(1.9rem, 4vw, 3rem); }
.about-section { margin-top: 26px; }
.about-section h2 { margin: 0 0 10px; font-family: var(--display); font-size: clamp(1.35rem, 2.4vw, 2rem); line-height: 1.2; }
.about-section p { margin: 8px 0; color: color-mix(in srgb, var(--text) 84%, var(--muted)); }
.about-section a { color: var(--primary-dark); font-weight: 800; }
.about-section a:hover { color: var(--accent); }
.not-found { text-align: center; }
.not-found h1 { font-size: clamp(5rem, 18vw, 10rem); }
.empty-state { padding: 34px; }

.auth-card { text-align: center; }
.auth-card .admin-form { max-width: 460px; margin: 24px auto 0; text-align: left; }
.admin-header, .editor-header, .upload-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.admin-actions.row { justify-content: flex-end; }
.admin-post-list { display: grid; gap: 16px; }
.admin-homepage-entry { margin-bottom: 18px; border-color: rgba(47, 109, 246, 0.24); }
.admin-homepage-entry h2 { font-weight: 900; }
.admin-post { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.admin-post h2 { margin: 10px 0 6px; font-family: var(--display); font-weight: 400; font-size: 2rem; }
.admin-post p { margin: 0 0 8px; color: var(--muted); }
.editor-form { gap: 18px; }
.editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.markdown-editor { min-height: 520px; font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; font-size: 0.95rem; line-height: 1.65; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.upload-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; min-width: min(480px, 100%); }
.cover-picker, .cover-editor-panel { display: grid; gap: 14px; }
body.modal-open { overflow: hidden; }
.cover-modal[hidden] { display: none; }
.cover-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
}
.cover-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 16, 15, 0.58);
  backdrop-filter: blur(12px);
}
.cover-modal-dialog {
  position: relative;
  width: min(1180px, 100%);
  max-height: min(880px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 30px;
  background: var(--card);
  box-shadow: 0 30px 110px rgba(0, 0, 0, 0.38);
  padding: clamp(20px, 4vw, 34px);
  backdrop-filter: blur(26px) saturate(1.18);
}
.cover-modal-head,
.cover-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.cover-modal-head { margin-bottom: 18px; }
.cover-modal-head h2 {
  margin: 4px 0 6px;
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1;
}
.cover-modal-actions { justify-content: flex-end; margin-top: 18px; }
.modal-layout { grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr); }
.editor-help-card {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(47, 109, 246, 0.24);
  border-radius: 20px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(47, 109, 246, 0.13), rgba(232, 93, 117, 0.12));
  padding: 14px 16px;
}
.editor-help-card strong { font-family: var(--ui); font-weight: 900; }
.editor-help-card span { color: var(--muted); font-size: 0.94rem; }
.cover-picker-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.cover-picker h2, .cover-editor-panel h2 { margin: 0; font-family: var(--display); font-size: 2rem; }
.cover-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}
.cover-editor-stage,
.cover-preview {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    linear-gradient(45deg, rgba(122, 108, 94, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(122, 108, 94, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(122, 108, 94, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(122, 108, 94, 0.08) 75%);
  background-color: rgba(255, 255, 255, 0.26);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}
.cover-editor-stage {
  aspect-ratio: 16 / 9;
  cursor: grab;
  user-select: none;
}
.cover-editor-stage:active { cursor: grabbing; }
.cover-editor-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--editor-cover-image) var(--editor-cover-x, 50%) var(--editor-cover-y, 50%) / cover no-repeat;
  transform: scale(var(--editor-cover-zoom, 1));
  transform-origin: var(--editor-cover-x, 50%) var(--editor-cover-y, 50%);
  pointer-events: none;
}
.cover-editor-stage.hero-preview::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  height: var(--cover-hero-fade-height, 12.4%);
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
}
.cover-editor-stage img { display: none; }
.cover-empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}
.cover-editor-stage.has-image .cover-empty-state { display: none; }
.cover-editor-controls { display: grid; gap: 14px; }
.cover-target-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(197, 138, 42, 0.11);
}
.cover-target-tabs.single { grid-template-columns: 1fr; }
.cover-target-tabs button {
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-family: var(--ui);
  font-weight: 900;
  padding: 10px 12px;
}
.cover-target-tabs button.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  box-shadow: 0 12px 26px rgba(47, 109, 246, 0.22);
}
.cover-preview-stack { display: grid; gap: 12px; }
.cover-preview-stack span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 800;
}
.cover-preview {
  min-height: 160px;
}
.cover-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--preview-cover-image) var(--preview-cover-x, 50%) var(--preview-cover-y, 50%) / cover no-repeat;
  transform: scale(var(--preview-cover-zoom, 1));
  transform-origin: var(--preview-cover-x, 50%) var(--preview-cover-y, 50%);
}
.cover-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(9, 7, 6, 0.08), rgba(9, 7, 6, 0.78));
}
.cover-preview.hero-preview::after {
  inset: auto 0 0;
  height: var(--cover-hero-fade-height, 12.4%);
  background: linear-gradient(transparent, var(--bg));
}
.hero-preview { aspect-ratio: var(--cover-hero-ratio, 16 / 7); }
.card-preview { aspect-ratio: 141 / 100; }
.home-preview { aspect-ratio: 16 / 8; }
.media-folder-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.media-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-family: var(--ui);
  font-weight: 800;
}
.media-breadcrumbs a { color: var(--accent); }
.media-breadcrumbs span { color: var(--muted); }
.media-folder-create {
  display: flex;
  gap: 12px;
  align-items: end;
  margin: 0 0 18px;
}
.media-folder-create label { flex: 1; }
.media-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 0 0 18px;
}
.media-folder-tile {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(197, 138, 42, 0.1);
  padding: 12px;
}
.media-folder-tile a {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
}
.media-folder-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.45);
  font-family: var(--ui);
  font-weight: 900;
}
.media-library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.media-tile {
  position: relative;
  display: grid;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.28);
  padding: 0;
  text-align: left;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.media-tile:hover,
.media-tile.is-selected {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--border));
  box-shadow: 0 16px 34px rgba(232, 93, 117, 0.18);
  transform: translateY(-2px);
}
.media-tile img {
  width: 100%;
  height: 260px;
  background:
    linear-gradient(45deg, rgba(122, 108, 94, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(122, 108, 94, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(122, 108, 94, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(122, 108, 94, 0.08) 75%);
  background-color: rgba(255, 255, 255, 0.26);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  object-fit: contain;
}
.media-tile > div,
.media-tile > span,
.media-select-button {
  display: grid;
  gap: 8px;
  padding: 12px;
}
.media-select-button {
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.media-select-button img {
  margin: -12px -12px 0;
  width: calc(100% + 24px);
}
.media-tile > span,
.media-select-button span,
.media-tile span {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--ui);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-tile form { padding: 0 12px 12px; }
.media-tile .btn { min-height: 36px; padding: 0 12px; font-size: 0.84rem; }
.avatar-library .media-tile { cursor: default; }
.editor-context-menu {
  position: fixed;
  z-index: 100;
  width: min(340px, calc(100vw - 24px));
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 12px;
  backdrop-filter: blur(22px);
}
.editor-context-menu strong {
  display: block;
  margin: 4px 6px 10px;
  font-family: var(--display);
  font-size: 1.2rem;
}
.editor-context-menu [data-context-media-list] { display: grid; gap: 8px; }
.editor-context-menu button {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 0;
  border-radius: 14px;
  color: var(--text);
  background: rgba(197, 138, 42, 0.1);
  cursor: pointer;
  padding: 7px;
  text-align: left;
}
.editor-context-menu button:hover { background: rgba(232, 93, 117, 0.14); }
.editor-context-menu img {
  width: 58px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
}
.editor-context-menu span {
  overflow: hidden;
  font-family: var(--ui);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; color: var(--muted); padding: 28px; }

@media (prefers-reduced-motion: no-preference) {
  .hero-inner, .post-hero-inner { animation: reveal-up 0.65s ease both; }
  .post-showcase-grid > *, .term-grid > *, .timeline, .about-card { animation: reveal-up 0.55s ease both; }
  .post-showcase-grid > :nth-child(2), .term-grid > :nth-child(2) { animation-delay: 0.06s; }
  .post-showcase-grid > :nth-child(3), .term-grid > :nth-child(3) { animation-delay: 0.12s; }
}

@keyframes reveal-up {
  from { opacity: 0; translate: 0 14px; }
  to { opacity: 1; translate: 0 0; }
}

@media (max-width: 980px) {
  .layout,
  .layout.post-layout {
    width: min(100% - 24px, 760px);
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .content-panel { min-width: 0; }
  .sidebar, .post-layout .sidebar {
    position: static;
    top: auto;
    grid-row: auto;
    width: 100%;
    transform: none;
  }
  .profile-card, .side-card { width: 100%; }
  .side-cover-card { width: 100%; }
  .layout.home-layout .content-panel,
  .layout.home-layout .showcase-card:nth-child(even),
  .layout.home-layout .showcase-card:nth-child(even):hover {
    transform: none;
  }
  .admin-post, .admin-header, .editor-header, .upload-card { grid-template-columns: 1fr; flex-direction: column; align-items: flex-start; }
}
@media (max-width: 720px) {
  html { scroll-padding-top: 88px; }
  body.menu-open { overscroll-behavior: none; }
  .topbar {
    top: max(9px, env(safe-area-inset-top));
    right: max(9px, env(safe-area-inset-right));
    left: max(9px, env(safe-area-inset-left));
    display: grid;
    width: auto;
    min-height: 58px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    border-radius: 24px;
    padding: 7px 9px;
    transform: none;
  }
  .topbar.is-hidden { transform: translateY(calc(-100% - env(safe-area-inset-top) - 18px)); }
  .brand {
    display: flex;
    min-width: 0;
    align-items: center;
    overflow: hidden;
    padding: 0 6px 0 0;
    font-size: 1.02rem;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .brand::before {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    margin-right: 9px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
    color: #fff;
    font-size: 1rem;
  }
  .topbar-actions { justify-self: end; gap: 2px; }
  .theme-toggle,
  .menu-toggle {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 9px;
  }
  .js .menu-toggle { display: grid; }
  .nav {
    grid-column: 1 / -1;
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 8px;
  }
  .nav a {
    display: grid;
    min-height: 46px;
    place-items: center;
    padding: 8px;
    text-align: center;
    line-height: 1.15;
  }
  .js .nav {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    max-height: calc(100dvh - 92px - env(safe-area-inset-top));
    overflow-y: auto;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 22px;
    visibility: hidden;
    background: color-mix(in srgb, var(--card) 94%, var(--bg));
    box-shadow: 0 22px 62px rgba(31, 23, 18, 0.22);
    opacity: 0;
    padding: 10px;
    pointer-events: none;
    transform: translateY(-8px) scale(0.98);
    transform-origin: top;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    overscroll-behavior: contain;
    backdrop-filter: blur(24px) saturate(1.2);
  }
  .js .topbar.is-menu-open .nav {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }
  .topbar.is-menu-open + .menu-scrim {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }
  .flash-stack {
    top: calc(max(76px, env(safe-area-inset-top) + 66px));
    right: max(9px, env(safe-area-inset-right));
    left: max(9px, env(safe-area-inset-left));
    width: auto;
  }
  .hero {
    min-height: min(680px, 100svh);
    place-items: end center;
    padding: 132px 18px 92px;
    padding-right: max(18px, env(safe-area-inset-right));
    padding-left: max(18px, env(safe-area-inset-left));
  }
  .hero::before {
    background:
      linear-gradient(180deg, rgba(9, 7, 16, 0.16) 0%, rgba(13, 11, 20, 0.5) 48%, rgba(9, 7, 12, 0.9) 100%),
      var(--cover-image, url('/blog/static/img/hero.svg')) var(--cover-x, 50%) var(--cover-y, 50%) / cover no-repeat;
    filter: blur(16px) saturate(0.84) brightness(0.78);
    transform: scale(1.12);
  }
  .hero-cover-image,
  .post-hero-cover-image {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 82px);
    left: 50%;
    z-index: 1;
    display: block;
    width: min(calc(100% - 36px - env(safe-area-inset-left) - env(safe-area-inset-right)), 620px);
    height: clamp(230px, 40vw, 300px);
    padding: 4px;
    transform: translateX(-50%);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 22px;
    background: rgba(9, 8, 12, 0.66);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
    object-fit: contain;
    object-position: center;
    pointer-events: none;
    user-select: none;
  }
  .hero h1 { font-size: clamp(2.8rem, 13vw, 4.8rem); line-height: 0.98; text-wrap: balance; }
  .hero p { max-width: 34rem; font-size: 0.98rem; line-height: 1.75; }
  .hero-actions {
    display: grid;
    width: min(100%, 400px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 28px auto 0;
  }
  .hero-actions .btn { width: 100%; min-height: 48px; padding-inline: 14px; }
  .layout,
  .layout.post-layout {
    width: auto;
    margin-right: max(9px, env(safe-area-inset-right));
    margin-left: max(9px, env(safe-area-inset-left));
  }
  .layout { gap: 18px; margin-top: -42px; margin-bottom: 64px; }
  .layout.home-layout { margin-top: 24px; }
  .layout.subpage { margin-top: 104px; }
  .layout.post-layout { margin-top: 9px; }
  .layout.single-column { margin-top: 94px; }
  .sidebar { display: none; }
  .section-heading { margin-bottom: 16px; padding: 18px 4px 0; }
  .section-heading.compact { padding-top: 0; }
  .section-heading h1,
  .section-heading h2 { font-size: clamp(2.15rem, 10vw, 3rem); text-wrap: balance; }
  .post-hero {
    min-height: clamp(440px, 76svh, 560px);
    place-items: end center;
    padding: 112px 18px 72px;
    padding-right: max(18px, env(safe-area-inset-right));
    padding-left: max(18px, env(safe-area-inset-left));
  }
  .post-hero[style*="--cover-image"] { min-height: clamp(640px, 82svh, 700px); }
  .post-hero[style*="--cover-image"]::before {
    background:
      linear-gradient(180deg, rgba(9, 7, 6, 0.16) 0%, rgba(9, 7, 6, 0.38) 44%, rgba(9, 7, 6, 0.88) 100%),
      linear-gradient(135deg, rgba(15, 23, 42, 0.14), rgba(88, 28, 135, 0.1)),
      var(--cover-image) var(--cover-x, 50%) var(--cover-y, 50%) / cover no-repeat;
    filter: blur(16px) saturate(0.84) brightness(0.74);
    transform: scale(1.12);
  }
  .post-hero h1 { font-size: clamp(2.1rem, 10.5vw, 3.4rem); line-height: 1.05; text-wrap: balance; }
  .post-hero p { max-width: 34rem; font-size: 0.94rem; line-height: 1.72; }
  .post-hero::after { height: 44px; }
  .post-title-row { flex-direction: column; gap: 12px; margin-block: 14px; }
  .article,
  .comments { padding: 20px 16px; border-radius: 22px; }
  .article { overflow: hidden; padding-top: 14px; }
  .article-content { overflow-wrap: anywhere; font-size: 1rem; line-height: 1.86; }
  .article-content h1 { font-size: 2rem; }
  .article-content h2 { font-size: 1.58rem; }
  .article-content h3 { font-size: 1.3rem; }
  .article-content img { width: auto; max-width: 100%; height: auto; border-radius: 16px; }
  .article-content pre { max-width: 100%; border-radius: 16px; padding: 15px; }
  .article-content :where(video, iframe) { border-radius: 16px; }
  .article-tags a,
  .tag-cloud a { min-height: 40px; padding: 8px 11px; }
  .comment-form .btn { width: 100%; min-height: 48px; }
  .comment-item { grid-template-columns: 42px minmax(0, 1fr); gap: 12px; }
  .comment-avatar { width: 42px; height: 42px; border-radius: 14px; }
  .post-card,
  .post-card.small { grid-template-columns: 1fr; }
  .post-cover { min-height: 190px; }
  .post-showcase-grid,
  .media-library { grid-template-columns: 1fr; gap: 14px; }
  .showcase-card,
  .showcase-card.small { width: 100%; min-height: 340px; aspect-ratio: 4 / 3; border-radius: 24px; }
  .showcase-overlay { inset: auto 18px 18px; gap: 8px; }
  .showcase-overlay h2 { font-size: clamp(1.75rem, 7vw, 2.35rem); }
  .showcase-overlay p { -webkit-line-clamp: 2; }
  .showcase-overlay .post-tags span:nth-child(n + 4) { display: none; }
  .term-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .term-card { min-height: 104px; align-content: space-between; padding: 16px; border-radius: 20px; }
  .term-card strong { overflow-wrap: anywhere; font-size: 1.08rem; line-height: 1.3; }
  .term-card span { font-size: 0.84rem; }
  .timeline { gap: 22px; padding: 20px 12px; }
  .year-block h2 { padding-inline: 8px; }
  .timeline-item {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 3px 12px;
    min-height: 66px;
    align-items: center;
    padding: 10px 8px;
  }
  .timeline-item time {
    grid-row: 1 / 3;
    align-self: stretch;
    display: grid;
    min-width: 58px;
    place-items: center;
    border-radius: 14px;
    background: rgba(197, 138, 42, 0.11);
    font-family: var(--ui);
    font-weight: 800;
  }
  .timeline-item span { min-width: 0; line-height: 1.35; }
  .timeline-item small { grid-column: 2; line-height: 1.3; }
  .about-card,
  .timeline { border-radius: 22px; }
  .about-section a { overflow-wrap: anywhere; }
  input { min-height: 48px; }
  .editor-grid,
  .upload-form,
  .cover-editor-layout,
  .modal-layout { grid-template-columns: 1fr; }
  .cover-modal {
    padding: max(9px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-right)) max(9px, env(safe-area-inset-bottom)) max(9px, env(safe-area-inset-left));
  }
  .cover-modal-dialog { max-height: calc(100dvh - 18px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); border-radius: 22px; }
  .cover-picker-head,
  .admin-profile-strip { align-items: flex-start; flex-direction: column; }
  .footer {
    align-items: center;
    flex-direction: column;
    gap: 4px;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    font-size: 0.82rem;
  }
}
@media (max-width: 420px) {
  .topbar {
    right: max(7px, env(safe-area-inset-right));
    left: max(7px, env(safe-area-inset-left));
    min-height: 56px;
    padding: 7px;
    border-radius: 22px;
  }
  .brand { font-size: 0.98rem; }
  .brand::before {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    margin-right: 8px;
  }
  .theme-toggle,
  .menu-toggle {
    width: 38px;
    min-width: 38px;
    height: 38px;
    font-size: 0.84rem;
    padding: 8px;
  }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav a { font-size: 0.86rem; }
  .hero {
    min-height: min(640px, 100svh);
    padding-top: 116px;
    padding-bottom: 76px;
  }
  .hero-cover-image,
  .post-hero-cover-image {
    top: calc(env(safe-area-inset-top) + 74px);
    width: min(calc(100% - 28px - env(safe-area-inset-left) - env(safe-area-inset-right)), 620px);
    height: clamp(230px, 64vw, 250px);
    padding: 3px;
    border-radius: 18px;
  }
  .hero h1 { margin-block: 12px; font-size: clamp(2.65rem, 14vw, 3.8rem); }
  .hero p { font-size: 0.92rem; }
  .hero-actions { margin-top: 24px; }
  .hero-actions .btn { min-height: 46px; font-size: 0.9rem; }
  .layout,
  .layout.post-layout {
    margin-right: max(7px, env(safe-area-inset-right));
    margin-left: max(7px, env(safe-area-inset-left));
  }
  .layout.subpage { margin-top: 96px; }
  .post-hero { min-height: max(410px, 72svh); padding: 102px 14px 62px; }
  .post-hero h1 { font-size: clamp(2rem, 11vw, 2.9rem); }
  .post-meta { gap: 7px 9px; font-size: 0.74rem; }
  .article,
  .comments,
  .profile-card,
  .side-card { padding: 16px 14px; border-radius: 20px; }
  .article { padding-top: 12px; }
  .article-content { font-size: 0.98rem; line-height: 1.84; }
  .article-content h1 { font-size: 1.8rem; }
  .article-content h2 { font-size: 1.48rem; }
  .article-content h3 { font-size: 1.24rem; }
  .article-content :where(img, video, iframe) { border-radius: 14px; }
  .showcase-card,
  .showcase-card.small { min-height: 340px; aspect-ratio: 1 / 1.06; border-radius: 22px; }
  .showcase-overlay { inset: auto 16px 16px; }
  .showcase-overlay h2 { font-size: clamp(1.65rem, 8vw, 2.05rem); }
  .showcase-overlay .post-tags span:nth-child(n + 3) { display: none; }
  .term-card { min-height: 96px; padding: 14px; border-radius: 18px; }
  .timeline { padding-inline: 8px; }
  .timeline-item { gap: 3px 9px; }
  .timeline-item time { min-width: 54px; }
  .cover-modal-head,
  .cover-modal-actions { align-items: stretch; flex-direction: column; }
  .cover-modal-actions .btn { width: 100%; }
}

@media (hover: none), (pointer: coarse) {
  .nav a:hover,
  .theme-toggle:hover,
  .menu-toggle:hover,
  .btn:hover,
  .showcase-card:hover,
  .side-cover-card:hover,
  .post-card:hover,
  .github-badge:hover,
  .media-tile:hover {
    transform: none;
  }
  .showcase-card:hover,
  .side-cover-card:hover { filter: none; }
  .showcase-card:active,
  .term-card:active,
  .timeline-item:active,
  .side-cover-card:active { transform: scale(0.992); }
  .btn:active,
  .theme-toggle:active,
  .menu-toggle:active { opacity: 0.76; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
  .topbar.is-hidden { transform: translateX(-50%); }
  .nav a:hover, .nav a.is-active, .theme-toggle:hover, .menu-toggle:hover,
  .btn:hover, .showcase-card:hover, .side-cover-card:hover, .post-card:hover {
    transform: none;
  }
}
