:root {
  --ink: #18231d;
  --muted: #657266;
  --dim: #849082;
  --bg: #f6f2e8;
  --surface: rgba(255, 255, 255, 0.56);
  --surface-solid: #fffaf0;
  --panel: rgba(255, 255, 255, 0.68);
  --panel-2: rgba(245, 240, 226, 0.86);
  --line: rgba(34, 44, 36, 0.13);
  --signal: #1a8f4a;
  --signal-soft: rgba(26, 143, 74, 0.16);
  --amber: #bd7c25;
  --cyan: #2d7f8f;
  --danger: #c45035;
  --shadow: 0 24px 70px rgba(26, 31, 25, 0.13);
  --glass-bg: rgba(255, 255, 255, 0.58);
  --glass-border: rgba(255, 255, 255, 0.68);
  --max: 1180px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --ink: #f1f5e9;
  --muted: #a8b1a7;
  --dim: #6f7b75;
  --bg: #0b0d0b;
  --surface: rgba(17, 24, 20, 0.66);
  --surface-solid: #111814;
  --panel: rgba(17, 24, 20, 0.74);
  --panel-2: rgba(23, 33, 29, 0.82);
  --line: rgba(190, 221, 187, 0.18);
  --signal: #22ff57;
  --signal-soft: rgba(34, 255, 87, 0.16);
  --amber: #d7a94c;
  --cyan: #66c7cf;
  --danger: #ff6d4a;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.32);
  --glass-bg: rgba(17, 24, 20, 0.58);
  --glass-border: rgba(190, 221, 187, 0.18);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(45, 127, 143, 0.16), transparent 32vw),
    radial-gradient(circle at 85% 12%, rgba(189, 124, 37, 0.12), transparent 30vw),
    linear-gradient(90deg, rgba(55, 65, 53, 0.045) 1px, transparent 1px) 0 0 / 72px 72px,
    linear-gradient(rgba(55, 65, 53, 0.035) 1px, transparent 1px) 0 0 / 72px 72px,
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  line-height: 1.7;
  transition: background-color 420ms cubic-bezier(0.16, 1, 0.3, 1), color 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  background-color: #fff;
  background-image: url("assets/img/ui/loading.gif");
  background-position: center;
  background-repeat: no-repeat;
  background-size: clamp(92px, 12vw, 150px);
  transition: opacity 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

body.page-transition-ready::after {
  animation: page-arrive-light 460ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

body.page-transition-ready.is-leaving::after {
  opacity: 0.86;
}

:root[data-theme="dark"] body::after {
  background-color: #050607;
}

:root[data-theme="dark"] body.page-transition-ready::after {
  animation-name: page-arrive-dark;
}

:root[data-theme="dark"] body.page-transition-ready.is-leaving::after {
  opacity: 0.72;
}

@keyframes page-arrive-light {
  from {
    opacity: 0.64;
  }
  to {
    opacity: 0;
  }
}

@keyframes page-arrive-dark {
  from {
    opacity: 0.78;
  }
  to {
    opacity: 0;
  }
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 14% 0%, rgba(34, 255, 87, 0.12), transparent 30vw),
    radial-gradient(circle at 86% 10%, rgba(102, 199, 207, 0.11), transparent 34vw),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 72px 72px,
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px) 0 0 / 72px 72px,
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("assets/img/backgrounds/newspaper.png");
  background-size: 520px auto;
  opacity: 0.04;
  mix-blend-mode: multiply;
}

:root[data-theme="dark"] body::before {
  opacity: 0.035;
  mix-blend-mode: screen;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--signal);
  color: var(--bg);
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -80px;
  z-index: 30;
  padding: 10px 14px;
  background: var(--signal);
  color: var(--bg);
  border-radius: 4px;
  font-weight: 700;
}

.skip-link:focus {
  top: 16px;
}

.loading-mask {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--signal) 18%, transparent), transparent 36%),
    color-mix(in srgb, var(--bg) 92%, transparent);
  opacity: 1;
  transition: opacity 0.52s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.52s cubic-bezier(0.16, 1, 0.3, 1);
}

.loading-mask.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  width: min(420px, 100%);
  padding: 22px;
  border-radius: 16px;
}

.loading-gif {
  width: 92px;
  height: 92px;
  margin: 0 auto 14px;
  object-fit: contain;
}

.loading-title {
  margin-bottom: 14px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.loading-track {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.loading-track span {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--signal), var(--cyan), var(--amber));
  transform: scaleX(0.12);
  transform-origin: left center;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.glass {
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  box-shadow: var(--shadow);
}

@supports ((backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px))) {
  .glass {
    backdrop-filter: blur(22px) saturate(1.25);
    -webkit-backdrop-filter: blur(22px) saturate(1.25);
  }
}

@supports not ((backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px))) {
  .glass {
    background: var(--panel-2);
  }
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 74px;
  margin: 12px clamp(14px, 3vw, 28px) 0;
  padding: 12px clamp(16px, 3vw, 28px);
  border-radius: 14px;
}

.site-header.is-elevated {
  transform: translateY(-4px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-2);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  color: var(--signal);
  font-size: 15px;
  letter-spacing: 0;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.site-nav a,
.theme-toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.site-nav a:hover,
.site-nav a:focus-visible,
.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.blog-hero {
  position: relative;
  width: min(var(--max), calc(100% - 36px));
  min-height: min(760px, calc(100vh - 92px));
  display: grid;
  align-content: center;
  margin: 0 auto;
  padding: clamp(78px, 12vw, 150px) 0 clamp(60px, 8vw, 100px);
}

.hero {
  position: relative;
  min-height: 78vh;
  display: grid;
  align-items: end;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.hero-media,
.hero-shade {
  position: absolute;
  inset: 0;
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.08) contrast(1.05);
}

.hero-shade {
  background:
    linear-gradient(90deg, rgba(4, 8, 6, 0.92), rgba(4, 8, 6, 0.58) 48%, rgba(4, 8, 6, 0.14)),
    linear-gradient(0deg, rgba(11, 13, 11, 1) 0, transparent 42%);
}

.hero-content {
  position: relative;
  width: min(var(--max), calc(100% - 36px));
  margin: 0 auto;
  padding: 110px 0 74px;
}

.curve-art {
  position: absolute;
  pointer-events: none;
  overflow: visible;
  opacity: 0.46;
}

.curve-art path {
  fill: none;
  stroke: var(--signal);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.32;
  transform-origin: center;
  animation: curveFloat 14s cubic-bezier(0.16, 1, 0.3, 1) infinite alternate;
}

.curve-art path + path {
  stroke: var(--cyan);
  animation-delay: -4s;
}

.curve-art-home {
  width: min(820px, 90vw);
  height: auto;
  right: -180px;
  top: 80px;
}

.curve-art-hero {
  width: min(760px, 78vw);
  right: -120px;
  bottom: 20px;
}

@keyframes curveFloat {
  from {
    transform: translate3d(-8px, 10px, 0) scale(1);
  }
  to {
    transform: translate3d(12px, -8px, 0) scale(1.03);
  }
}

.eyebrow,
.section-kicker,
.article-meta,
.post-meta {
  color: var(--signal);
  font-family: "Consolas", "Cascadia Mono", monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 18px;
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 970px;
  margin-bottom: 24px;
  color: var(--ink);
  font-size: clamp(48px, 9vw, 128px);
  line-height: 0.92;
  letter-spacing: 0;
}

.project-hero h1 {
  color: #fff;
  font-size: clamp(58px, 12vw, 164px);
  line-height: 0.86;
}

h2 {
  margin-bottom: 18px;
  color: var(--ink);
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.12;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0;
}

p {
  color: var(--muted);
}

.hero-copy {
  max-width: 720px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: clamp(18px, 2.2vw, 24px);
}

.project-hero .hero-copy {
  color: #dce7dc;
}

.hero-actions,
.post-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.button.primary {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--bg);
}

.button.ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.12);
}

.project-hero .button.ghost {
  color: #fff;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

.section {
  width: min(var(--max), calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(58px, 9vw, 112px) 0;
}

.compact-section {
  padding: clamp(42px, 7vw, 82px) 0;
}

.section + .section {
  border-top: 1px solid var(--line);
}

.section-kicker {
  margin-bottom: 18px;
  font-size: 12px;
}

.intro-grid,
.materials-layout,
.featured-project {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.92fr);
  gap: clamp(28px, 6vw, 72px);
  align-items: start;
}

.featured-project {
  padding: clamp(22px, 4vw, 36px);
  border-radius: 24px;
  overflow: hidden;
}

.featured-media {
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
  align-self: stretch;
}

.featured-media img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0;
}

.pill-row span {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
}

.project-facts {
  border-radius: 18px;
  overflow: hidden;
}

.project-facts dl {
  margin: 0;
}

.project-facts div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.project-facts div:last-child {
  border-bottom: 0;
}

.project-facts dt {
  color: var(--dim);
  font-size: 13px;
}

.project-facts dd {
  margin: 0;
  color: var(--ink);
}

.loop-track {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.loop-step {
  min-height: 250px;
  padding: 26px;
  border-radius: 18px;
}

.loop-step span {
  display: inline-block;
  margin-bottom: 38px;
  color: var(--amber);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 14px;
}

.split-heading {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(280px, 0.8fr);
  gap: 34px;
  align-items: end;
  margin-bottom: 28px;
}

.split-heading p {
  margin-bottom: 20px;
}

.text-link {
  color: var(--signal);
  font-weight: 700;
  justify-self: end;
  align-self: center;
}

.loud-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--signal-soft);
}

.loud-link::after {
  content: "→";
}

.text-link:hover,
.text-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.architecture-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.layer,
.article-card,
.blog-entry,
.note-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
}

.layer,
.article-card,
.note-card {
  padding: 24px;
}

.layer::before,
.article-card::before,
.blog-entry::before,
.note-card::before,
.featured-project::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.32), transparent 26%);
  opacity: 0;
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="dark"] .layer::before,
:root[data-theme="dark"] .article-card::before,
:root[data-theme="dark"] .blog-entry::before,
:root[data-theme="dark"] .note-card::before,
:root[data-theme="dark"] .featured-project::before {
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(34, 255, 87, 0.18), transparent 28%);
}

.tilt-card:hover::before,
.tilt-card:focus-within::before {
  opacity: 1;
}

.tilt-card {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translate3d(0, 0, 0);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

.layer b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--signal);
  font-family: "Consolas", "Cascadia Mono", monospace;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.article-card h3 a,
.blog-entry h3 a,
.post-list h2 a {
  color: var(--ink);
}

.article-card h3 a:hover,
.article-card h3 a:focus-visible,
.blog-entry h3 a:hover,
.blog-entry h3 a:focus-visible,
.post-list h2 a:hover,
.post-list h2 a:focus-visible {
  color: var(--signal);
  outline: none;
}

.article-meta,
.post-meta {
  margin-bottom: 12px;
  color: var(--amber);
  font-size: 12px;
}

.blog-entry-list {
  display: grid;
  gap: 14px;
}

.blog-entry {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 24px;
  padding: 22px;
}

.blog-entry time {
  color: var(--dim);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 13px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.wide-figure {
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
}

.wide-figure img {
  display: block;
  width: 100%;
}

.wide-figure figcaption {
  padding: 16px 18px;
  color: var(--muted);
  font-size: 14px;
}

.diagram-figure {
  margin-top: 18px;
}

.diagram-figure img {
  height: min(680px, 72vh);
  object-fit: contain;
  object-position: center;
  background: rgba(0, 0, 0, 0.16);
}

.mermaid-figure {
  padding: 0;
}

.mermaid-figure figcaption {
  border-top: 1px solid var(--line);
}

.mermaid-source {
  display: none;
}

.mermaid-output {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  margin: 0;
  padding: 22px;
  overflow: auto;
  color: var(--ink);
  font-family: "Consolas", "Cascadia Mono", "Microsoft YaHei", monospace;
  font-size: 14px;
  background:
    linear-gradient(90deg, rgba(45, 127, 143, 0.08) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(45, 127, 143, 0.06) 1px, transparent 1px) 0 0 / 28px 28px,
    rgba(0, 0, 0, 0.04);
  white-space: pre;
}

.mermaid-output svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  min-width: 720px;
  overflow: visible;
}

.mermaid-compact .mermaid-output {
  min-height: 250px;
  padding: 14px 18px;
}

.mermaid-compact .mermaid-output svg {
  width: min(760px, 100%);
  min-width: 0;
}

.mermaid-ending-compact .mermaid-output svg {
  width: min(700px, 100%);
}

.sequence-figure .mermaid-output {
  display: block;
  min-height: 560px;
  max-height: none;
  padding: 24px 28px 36px 46px;
  overflow-x: auto;
  overflow-y: visible;
  white-space: normal;
}

.sequence-figure .mermaid-output svg {
  width: 1220px;
  max-width: none;
  min-width: 1180px;
  height: auto;
  margin: 0 auto;
  overflow: visible;
}

.mermaid-output.is-error {
  justify-content: flex-start;
  color: var(--danger);
}

.sequence-static-figure {
  overflow: visible;
}

.sequence-static-figure figcaption {
  border-top: 1px solid var(--line);
}

.sequence-static-diagram {
  display: block;
  min-height: 0;
  padding: 22px 24px 28px;
  overflow-x: auto;
  overflow-y: visible;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(45, 127, 143, 0.08) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(45, 127, 143, 0.06) 1px, transparent 1px) 0 0 / 28px 28px,
    rgba(0, 0, 0, 0.04);
}

.sequence-static-diagram svg {
  display: block;
  width: 1180px;
  max-width: none;
  min-width: 0;
  height: auto;
  aspect-ratio: 1460 / 1120;
  margin: 0 auto;
  overflow: visible;
}

.seq-actors rect {
  fill: var(--panel-2);
  stroke: var(--cyan);
  stroke-width: 1.4;
}

.seq-actors text,
.seq-messages text,
.seq-notes text {
  fill: var(--ink);
  font-family: "Consolas", "Cascadia Mono", "Microsoft YaHei", monospace;
  font-size: 16px;
  text-anchor: middle;
  dominant-baseline: middle;
}

.seq-lines line {
  stroke: var(--cyan);
  stroke-width: 1.6;
  opacity: 0.9;
}

.seq-messages line,
.seq-messages path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  marker-end: url("#seqArrow");
}

.seq-messages .seq-return {
  stroke-dasharray: 7 5;
}

.seq-arrow-head {
  fill: var(--ink);
}

.seq-notes rect {
  fill: rgba(215, 169, 76, 0.16);
  stroke: var(--amber);
  stroke-width: 1.5;
}

.embed-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
  box-shadow: var(--shadow);
}

.embed-frame iframe,
.embed-frame video {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.capture-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.capture-grid + .wide-figure {
  margin-top: 16px;
}

.capture-grid .wide-figure img {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.material-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
}

.material-list li {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.material-list li:last-child {
  border-bottom: 0;
}

.material-list strong {
  color: var(--ink);
}

.material-list span {
  color: var(--muted);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 34px clamp(18px, 4vw, 44px);
  border-top: 1px solid var(--line);
  color: var(--dim);
}

.site-footer p {
  margin: 0;
  font-size: 14px;
}

.footer-muted {
  color: var(--dim);
}

.beian-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 16px;
}

.beian-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.beian-links .beian-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex: 0 0 auto;
}

.beian-links .beian-icon-miit {
  width: 20px;
  height: 20px;
}

.beian-links a:hover,
.beian-links a:focus-visible {
  color: var(--signal);
  outline: none;
}

.post-hero {
  width: min(var(--max), calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(70px, 11vw, 140px) 0 clamp(42px, 7vw, 82px);
}

.post-hero h1 {
  max-width: 920px;
  font-size: clamp(44px, 7vw, 86px);
  line-height: 0.98;
}

.post-lead {
  max-width: 780px;
  color: var(--muted);
  font-size: clamp(18px, 2vw, 22px);
}

.post-shell {
  width: min(var(--max), calc(100% - 36px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(28px, 5vw, 62px);
  padding-bottom: clamp(70px, 10vw, 120px);
}

.toc {
  position: sticky;
  top: 110px;
  align-self: start;
  border-radius: 18px;
  padding: 14px;
  width: 58px;
  overflow: hidden;
  white-space: nowrap;
  transition: width 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.toc:hover,
.toc:focus-within {
  width: 250px;
}

.toc strong {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  margin-bottom: 10px;
  color: var(--signal);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toc strong::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 24px var(--signal);
}

.toc a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px 8px 28px;
  color: var(--muted);
  font-size: 14px;
  border-radius: 999px;
  opacity: 0.78;
}

.toc a::before {
  content: "";
  position: absolute;
  left: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}

.toc a:hover,
.toc a:focus-visible,
.toc a.is-active {
  color: var(--signal);
  background: var(--signal-soft);
  opacity: 1;
  outline: none;
}

.toc a.is-active::before {
  background: var(--signal);
}

.project-bookmark,
.code-bookmark {
  position: fixed;
  z-index: 18;
  top: 50%;
  max-height: min(76vh, 680px);
  overflow: visible;
  transition: transform 0.72s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.72s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

.project-bookmark.is-manual,
.code-bookmark.is-manual {
  transition-duration: 0.48s;
}

.project-bookmark {
  left: 0;
  width: 306px;
  padding: 16px 14px 16px 18px;
  border-left: 0;
  border-radius: 0 18px 18px 0;
  transform: translate3d(calc(-100% + 18px), -50%, 0);
}

.code-bookmark {
  right: 0;
  width: 318px;
  padding: 16px 18px 16px 14px;
  border-right: 0;
  border-radius: 18px 0 0 18px;
  transform: translate3d(calc(100% - 18px), -50%, 0);
}

.project-bookmark::after,
.code-bookmark::after {
  content: "";
  position: absolute;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--signal), var(--cyan), var(--amber));
  box-shadow: 0 0 18px var(--signal-soft);
}

.bookmark-tab {
  position: absolute;
  top: 28%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 58px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  color: var(--signal);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transform: translate3d(0, -50%, 0);
  transition: background-color 0.45s cubic-bezier(0.16, 1, 0.3, 1), color 0.45s cubic-bezier(0.16, 1, 0.3, 1), transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.bookmark-tab span {
  display: block;
  transform: rotate(0deg);
  transition: transform 0.48s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.project-bookmark .bookmark-tab {
  right: -28px;
  border-left: 0;
  border-radius: 0 16px 16px 0;
}

.code-bookmark .bookmark-tab {
  left: -28px;
  border-right: 0;
  border-radius: 16px 0 0 16px;
}

.bookmark-tab:hover,
.bookmark-tab:focus-visible,
.project-bookmark.is-manual .bookmark-tab,
.code-bookmark.is-manual .bookmark-tab {
  background: var(--signal-soft);
  color: var(--ink);
  outline: none;
}

.project-bookmark::after {
  inset: 18px 5px 18px auto;
}

.code-bookmark::after {
  inset: 18px auto 18px 5px;
}

.project-bookmark.is-auto-open,
.project-bookmark.is-manual-open,
.code-bookmark.is-auto-open,
.code-bookmark.is-manual-open {
  transform: translate3d(0, -50%, 0);
}

.project-bookmark.is-open .bookmark-tab span,
.code-bookmark.is-open .bookmark-tab span {
  transform: rotate(180deg);
}

.project-bookmark strong,
.code-bookmark strong {
  display: block;
  color: var(--signal);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-bookmark strong {
  margin: 0 18px 12px 0;
}

.code-bookmark strong {
  margin: 0 0 12px 18px;
  text-align: right;
}

.project-bookmark nav,
.code-bookmark nav {
  display: grid;
  gap: 4px;
  max-height: calc(min(76vh, 680px) - 44px);
  overflow: auto;
  scrollbar-width: thin;
}

.project-bookmark a,
.code-bookmark a {
  position: relative;
  display: block;
  width: 100%;
  padding: 8px 14px 8px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  cursor: pointer;
  transition: color 0.45s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.45s cubic-bezier(0.16, 1, 0.3, 1), transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.code-bookmark a {
  padding: 8px 18px 8px 14px;
  font-size: 13px;
  text-align: right;
}

.code-bookmark .bookmark-level-2 {
  width: calc(100% - 18px);
  margin-left: auto;
  color: var(--dim);
  font-size: 12px;
}

.project-bookmark a::before,
.code-bookmark a::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
  transform: translate3d(0, -50%, 0);
}

.project-bookmark a::before {
  left: 6px;
}

.code-bookmark a::before {
  right: 6px;
}

.code-bookmark .bookmark-level-2::before {
  width: 5px;
  height: 5px;
  opacity: 0.78;
}

.project-bookmark a:hover,
.project-bookmark a:focus-visible,
.project-bookmark a.is-active,
.project-bookmark a.is-page-active,
.code-bookmark a:hover,
.code-bookmark a:focus-visible,
.code-bookmark a.is-active,
.code-bookmark a.is-page-active {
  color: var(--signal);
  background: var(--signal-soft);
  outline: none;
}

.project-bookmark a.is-active,
.project-bookmark a.is-page-active,
.code-bookmark a.is-active,
.code-bookmark a.is-page-active {
  font-weight: 700;
}

.project-bookmark a.is-active,
.project-bookmark a.is-page-active {
  transform: translate3d(4px, 0, 0) scale(1.035);
}

.code-bookmark a.is-active,
.code-bookmark a.is-page-active {
  transform: translate3d(-4px, 0, 0) scale(1.035);
}

.project-bookmark a.is-active::before,
.project-bookmark a.is-page-active::before,
.code-bookmark a.is-active::before,
.code-bookmark a.is-page-active::before {
  background: var(--signal);
  box-shadow: 0 0 14px var(--signal);
}

.project-bookmark .bookmark-sub {
  margin-left: 18px;
  padding-left: 20px;
  font-size: 13px;
  color: var(--dim);
}

.project-bookmark .bookmark-sub::before {
  width: 5px;
  height: 5px;
  opacity: 0.8;
}

.story-beats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.story-beat {
  min-height: 100%;
  padding: 22px;
}

.story-beat span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-bottom: 18px;
  border-radius: 50%;
  background: var(--signal-soft);
  color: var(--signal);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 13px;
  font-weight: 700;
}

.story-beat h3 {
  margin: 0 0 10px;
}

.story-note {
  margin-top: 18px;
}

.post-content {
  min-width: 0;
  width: min(880px, 100%);
  margin: 0 auto;
}

.post-content section {
  padding: 0 0 44px;
  margin-bottom: 44px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 110px;
}

.post-content section:last-child {
  border-bottom: 0;
}

.post-content h2 {
  font-size: clamp(26px, 3vw, 42px);
}

.post-content h3 {
  margin-top: 28px;
}

.post-content ul,
.post-content ol {
  padding-left: 1.25rem;
  color: var(--muted);
}

.post-content li + li {
  margin-top: 8px;
}

.post-content .wide-figure {
  margin: 24px 0;
}

.post-content .sequence-figure {
  width: min(1320px, calc(100vw - 36px));
  margin-left: 50%;
  transform: translateX(-50%);
}

.post-content .wide-figure:last-child {
  margin-bottom: 0;
}

.note,
.code-panel,
.matrix,
.timeline,
.post-list article {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.note {
  padding: 18px;
  border-left: 4px solid var(--amber);
}

.note p:last-child {
  margin-bottom: 0;
}

.code-panel {
  overflow: auto;
  padding: 18px;
}

.code-panel pre[class*="language-"],
.code-panel code[class*="language-"] {
  background: transparent;
  text-shadow: none;
}

.code-panel pre[class*="language-"] {
  padding: 0;
}

.code-context {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.code-caption {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.7;
}

pre,
code {
  font-family: "Consolas", "Cascadia Mono", monospace;
}

pre {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

code {
  color: var(--ink);
  background: var(--signal-soft);
  border: 1px solid rgba(34, 143, 74, 0.16);
  border-radius: 4px;
  padding: 0.05em 0.28em;
}

pre code {
  background: transparent;
  border: 0;
  padding: 0;
}

.matrix {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.matrix div {
  padding: 18px;
  background: var(--panel);
}

.matrix b {
  display: block;
  margin-bottom: 8px;
  color: var(--signal);
}

.timeline {
  padding: 10px 0;
}

.timeline div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 22px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

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

.timeline b {
  color: var(--amber);
  font-family: "Consolas", "Cascadia Mono", monospace;
}

.post-list {
  display: grid;
  gap: 16px;
}

.post-list article {
  padding: 22px;
}

.post-list h2 {
  margin-bottom: 10px;
  font-size: clamp(24px, 3vw, 34px);
}

.wiki-hero {
  width: min(var(--max), calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(70px, 10vw, 126px) 0 clamp(28px, 5vw, 56px);
}

.wiki-hero h1 {
  max-width: 980px;
  font-size: clamp(42px, 6.5vw, 82px);
  line-height: 1;
}

.wiki-layout {
  width: min(var(--max), calc(100% - 36px));
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: clamp(18px, 4vw, 42px);
  align-items: start;
  margin: 0 auto;
  padding-bottom: clamp(70px, 10vw, 120px);
}

.wiki-sidebar {
  position: sticky;
  top: 108px;
  max-height: calc(100vh - 132px);
  overflow: auto;
  padding: 18px;
  border-radius: 18px;
  scrollbar-width: thin;
}

.wiki-sidebar strong {
  display: block;
  margin-bottom: 12px;
  color: var(--signal);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wiki-sidebar nav {
  display: grid;
  gap: 5px;
}

.wiki-sidebar a,
.wiki-empty-toc {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.wiki-sidebar .wiki-toc-level-3 {
  margin-left: 12px;
  color: var(--dim);
  font-size: 12px;
}

.wiki-sidebar a:hover,
.wiki-sidebar a:focus-visible {
  color: var(--signal);
  background: var(--signal-soft);
  outline: none;
}

.wiki-article {
  min-width: 0;
  padding: clamp(22px, 4vw, 44px);
  border-radius: 18px;
}

.wiki-source {
  display: inline-flex;
  max-width: 100%;
  margin-bottom: 24px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--dim);
  background: var(--signal-soft);
  font-size: 13px;
}

.wiki-source code {
  overflow-wrap: anywhere;
}

.wiki-article h2,
.wiki-article h3,
.wiki-article h4 {
  scroll-margin-top: 110px;
}

.wiki-article h2 {
  margin-top: 34px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  font-size: clamp(25px, 3vw, 38px);
}

.wiki-article h2:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.wiki-article h3 {
  margin-top: 26px;
  color: var(--ink);
}

.wiki-article p,
.wiki-article li {
  color: var(--muted);
}

.wiki-article ul,
.wiki-article ol {
  padding-left: 1.25rem;
}

.wiki-article li + li {
  margin-top: 7px;
}

.wiki-article blockquote {
  margin: 22px 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
}

.wiki-article blockquote p {
  margin: 0;
}

.wiki-code {
  margin: 18px 0 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.wiki-codebar {
  display: flex;
  justify-content: flex-end;
  min-height: 34px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-2) 74%, transparent);
}

.wiki-codebar span {
  color: var(--amber);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 12px;
  text-transform: uppercase;
}

.wiki-code pre {
  overflow: auto;
  padding: 18px;
}

.resource-grid,
.doc-topic-grid {
  display: grid;
  gap: 16px;
}

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

.doc-topic-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.resource-card,
.doc-topic {
  position: relative;
  overflow: hidden;
  padding: 24px;
  border-radius: 18px;
}

.resource-card h2,
.doc-topic h2 {
  margin-bottom: 12px;
  font-size: clamp(22px, 2.6vw, 32px);
}

.resource-card h2 a:hover,
.resource-card h2 a:focus-visible,
.md-card:hover,
.md-card:focus-visible {
  color: var(--signal);
  outline: none;
}

.md-stack {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
}

.md-card {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
  min-height: 78px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 12px;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 46%),
    color-mix(in srgb, var(--panel) 76%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: border-color 0.45s cubic-bezier(0.16, 1, 0.3, 1), color 0.45s cubic-bezier(0.16, 1, 0.3, 1), transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.md-card::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 8px;
  pointer-events: none;
}

.md-card span {
  grid-row: span 2;
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--amber);
  background: var(--signal-soft);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 12px;
  font-weight: 700;
}

.md-card strong {
  min-width: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.md-card small {
  min-width: 0;
  color: var(--dim);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 12px;
}

.md-card:hover,
.md-card:focus-visible {
  border-color: color-mix(in srgb, var(--signal) 58%, var(--line));
  transform: translateY(-2px);
}

.md-card:hover strong,
.md-card:focus-visible strong {
  color: var(--signal);
}

.reveal {
  opacity: 0;
  transform: translate3d(0, 28px, 0);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal.visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 1040px) {
  .post-shell,
  .wiki-layout {
    grid-template-columns: 1fr;
  }

  .wiki-sidebar {
    position: static;
    max-height: none;
  }

  .toc {
    position: sticky;
    top: 92px;
    z-index: 10;
    width: 100%;
  }

  .toc:hover,
  .toc:focus-within {
    width: 100%;
  }

  .toc a {
    display: inline-flex;
    margin-right: 6px;
  }

  .project-bookmark,
  .code-bookmark {
    top: auto;
    bottom: 18px;
    width: min(320px, calc(100vw - 28px));
    max-height: 62vh;
  }

  .project-bookmark {
    transform: translate3d(calc(-100% + 20px), 0, 0);
  }

  .code-bookmark {
    bottom: 92px;
    transform: translate3d(calc(100% - 20px), 0, 0);
  }

  .bookmark-tab {
    top: 30px;
    width: 32px;
    height: 48px;
  }

  .project-bookmark.is-auto-open,
  .project-bookmark.is-manual-open,
  .code-bookmark.is-auto-open,
  .code-bookmark.is-manual-open {
    transform: translate3d(0, 0, 0);
  }
}

@media (max-width: 920px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .intro-grid,
  .materials-layout,
  .featured-project,
  .split-heading {
    grid-template-columns: 1fr;
  }

  .loop-track,
  .architecture-map,
  .article-grid,
  .capture-grid,
  .matrix,
  .notes-grid,
  .resource-grid,
  .doc-topic-grid,
  .story-beats {
    grid-template-columns: 1fr;
  }

  .loop-step {
    min-height: auto;
  }

  .text-link {
    justify-self: start;
  }
}

@media (max-width: 560px) {
  .hero {
    min-height: 74vh;
  }

  .hero-content,
  .blog-hero,
  .section,
  .post-hero,
  .post-shell {
    width: min(100% - 28px, var(--max));
  }

  .project-facts div,
  .material-list li,
  .timeline div,
  .blog-entry {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .site-footer {
    flex-direction: column;
  }

  .diagram-figure img {
    height: min(520px, 70vh);
  }

  .mermaid-output {
    min-height: 260px;
    padding: 16px;
  }

  .mermaid-output svg {
    min-width: 640px;
  }

  .beian-links {
    justify-content: flex-start;
  }
}
