:root {
  --ink: #171a18;
  --ink-soft: #2c332f;
  --muted: #68716b;
  --paper: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --line: #d8ded9;
  --line-strong: #bdc8c0;
  --code: #101412;
  --accent: #247a59;
  --accent-2: #b36b16;
  --accent-3: #9f3f77;
  --accent-soft: #dfeee7;
  --shadow: 0 18px 40px rgba(23, 26, 24, 0.08);
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.site-body {
  margin: 0;
  background:
    linear-gradient(rgba(23, 26, 24, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 26, 24, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.72;
}

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

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

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

button,
input {
  font: inherit;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.skip-link:focus {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(23, 26, 24, 0.96);
  color: #edf4ef;
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.site-header__inner,
.site-main,
.site-footer__inner {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 72px;
}

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

.site-brand:hover {
  color: #f7fbf8;
}

.site-brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #9ce0bd;
  font-family: var(--mono);
  font-weight: 700;
}

.site-brand__text {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.site-brand__text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}

.site-brand__text small {
  overflow: hidden;
  max-width: 360px;
  color: #b8c6bd;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.site-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  color: #dbe5de;
  font-size: 0.9rem;
}

.site-nav__link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  background: #edf4ef;
}

.reading-progress {
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
}

.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #6cc89a, #d19b4e, #c0629a);
}

.site-main {
  padding: 34px 0 72px;
}

.home-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 32px;
  align-items: end;
  min-height: 430px;
  overflow: hidden;
  padding: 40px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(13, 18, 16, 0.94), rgba(13, 18, 16, 0.72) 46%, rgba(13, 18, 16, 0.42)),
    url("/images/lab-bg.png") center / cover no-repeat;
  color: #f7fbf8;
  box-shadow: var(--shadow);
}

.home-hero__content {
  max-width: 700px;
}

.section-kicker {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 700;
}

.home-hero .section-kicker,
.article-header .section-kicker {
  color: #f3b261;
}

.home-hero h1,
.page-hero h1,
.article-header h1 {
  margin: 0;
  max-width: 920px;
  font-size: 3.1rem;
  line-height: 1.08;
}

.home-hero p {
  max-width: 620px;
  color: #d7e4dc;
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.button-primary,
.button-secondary {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 6px;
  font-weight: 700;
}

.button-primary {
  background: #dfeee7;
  color: #123226;
}

.button-secondary {
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #f5faf7;
}

.button-primary:hover,
.button-secondary:hover {
  color: #123226;
  background: #ffffff;
}

.home-terminal {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(8, 11, 10, 0.68);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
}

.terminal-top {
  display: flex;
  gap: 7px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.terminal-top span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e26868;
}

.terminal-top span:nth-child(2) {
  background: #d8a84d;
}

.terminal-top span:nth-child(3) {
  background: #6dc18e;
}

.terminal-body {
  padding: 18px;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.terminal-body p {
  margin: 0;
  color: #b8c8bf;
}

.terminal-body p + p {
  margin-top: 10px;
}

.terminal-body b {
  color: #8fd4ad;
}

.terminal-body a,
.terminal-body span {
  color: #f7fbf8;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin: 22px 0 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.metric-strip span {
  padding: 18px;
  background: var(--surface);
  color: var(--muted);
}

.metric-strip strong {
  display: block;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1.3rem;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 34px;
  align-items: start;
}

.content-column {
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 18px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.75rem;
}

.featured-post,
.content-panel,
.empty-state,
.archive-year,
.side-panel,
.directory-card,
.article-body,
.toc-panel,
.article-nav a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 1px 0 rgba(23, 26, 24, 0.02);
}

.featured-post {
  margin-bottom: 30px;
  padding: 28px;
  border-left: 5px solid var(--accent);
}

.featured-post h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.18;
}

.featured-post h2 a,
.post-card h3 a,
.archive-year a,
.directory-card {
  color: var(--ink);
}

.featured-post p {
  max-width: 760px;
  color: var(--ink-soft);
}

.text-link {
  font-family: var(--mono);
  font-weight: 700;
}

.post-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.post-card {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 22px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.post-card__date {
  padding-top: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.88rem;
}

.post-card h3 {
  margin: 0;
  font-size: 1.42rem;
  line-height: 1.28;
}

.post-card p {
  margin: 10px 0 0;
  color: var(--ink-soft);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.84rem;
}

.post-meta span,
.post-meta time {
  display: inline-flex;
  align-items: center;
}

.post-meta span::before {
  content: "#";
  color: var(--accent-2);
}

.sidebar {
  position: sticky;
  top: 96px;
  display: grid;
  gap: 16px;
}

.side-panel {
  padding: 18px;
}

.side-panel__title {
  margin: 0 0 12px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.9rem;
}

.profile-panel p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.side-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
}

.side-stats span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.side-stats strong {
  color: var(--ink);
  font-family: var(--mono);
}

.compact-list {
  display: grid;
}

.compact-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
}

.compact-list a:first-child {
  border-top: 0;
  padding-top: 0;
}

.compact-list a:last-child {
  padding-bottom: 0;
}

.compact-list span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.compact-list time,
.compact-list b {
  flex: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
}

.compact-list a:hover span {
  color: var(--accent);
}

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

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.tag-chip:hover,
.tag-chip--solid {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #103225;
}

.tag-chip small {
  color: var(--muted);
}

.tag-list--large {
  gap: 12px;
}

.tag-list--large .tag-chip {
  min-height: 38px;
  padding: 6px 12px;
}

.search-input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--ink);
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 122, 89, 0.14);
}

.search-results {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.search-result {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
}

.search-result span,
.search-results p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.page-hero {
  margin-bottom: 30px;
  padding: 34px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(23, 26, 24, 0.92), rgba(23, 26, 24, 0.72)),
    url("/images/lab-bg.png") center / cover no-repeat;
  color: #f7fbf8;
  box-shadow: var(--shadow);
}

.page-hero p {
  max-width: 740px;
  color: #d6e4dc;
}

.page-hero h1 {
  font-size: 2.45rem;
}

.content-panel,
.empty-state {
  padding: 28px;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.archive-list {
  display: grid;
  gap: 18px;
}

.archive-year {
  padding: 22px;
}

.archive-year h2 {
  margin: 0 0 16px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 1.25rem;
}

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

.directory-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
}

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

.directory-card span {
  overflow-wrap: anywhere;
  font-weight: 700;
}

.directory-card strong {
  color: var(--muted);
  font-family: var(--mono);
}

.article-main {
  width: min(1220px, calc(100% - 48px));
}

.article-wrap {
  display: grid;
  gap: 26px;
}

.article-header {
  padding: 36px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(23, 26, 24, 0.94), rgba(23, 26, 24, 0.74)),
    url("/images/lab-bg.png") center / cover no-repeat;
  color: #f7fbf8;
  box-shadow: var(--shadow);
}

.article-header h1 {
  margin-top: 12px;
  font-size: 2.55rem;
}

.article-header .post-meta {
  color: #d7e4dc;
}

.article-header .tag-list {
  margin-top: 20px;
}

.article-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: start;
}

.article-body {
  min-width: 0;
  padding: 38px;
}

.article-prose {
  color: var(--ink);
  font-size: 1.02rem;
}

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

.article-prose p,
.article-prose ul,
.article-prose ol,
.article-prose blockquote,
.article-prose table,
.article-prose figure,
.article-prose pre {
  margin: 0 0 1.25rem;
}

.article-prose h1,
.article-prose h2,
.article-prose h3,
.article-prose h4,
.article-prose h5,
.article-prose h6 {
  margin: 2.2rem 0 0.8rem;
  color: var(--ink);
  line-height: 1.28;
}

.article-prose h1 {
  font-size: 2rem;
}

.article-prose h2 {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 1.65rem;
}

.article-prose h3 {
  font-size: 1.35rem;
}

.article-prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

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

.article-prose blockquote {
  padding: 14px 16px;
  border-left: 4px solid var(--accent-2);
  border-radius: 0 8px 8px 0;
  background: #fbf7ee;
  color: var(--ink-soft);
}

.article-prose code,
.article-prose pre,
.article-prose figure.highlight {
  font-family: var(--mono);
}

.article-prose :not(pre) > code {
  padding: 2px 6px;
  border: 1px solid #cbd5ce;
  border-radius: 5px;
  background: #edf3ef;
  color: #11553d;
  font-size: 0.92em;
}

.article-prose pre,
.article-prose figure.highlight,
.article-prose .highlight {
  overflow-x: auto;
  border-radius: 8px;
  background: var(--code);
  color: #d8e8dd;
}

.article-prose pre {
  padding: 18px;
}

.article-prose pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

figure.highlight {
  margin: 0 0 1.25rem;
}

figure.highlight table {
  display: table;
  width: 100%;
  border: 0;
}

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

figure.highlight pre {
  margin: 0;
  padding: 18px;
}

figure.highlight .gutter {
  width: 1%;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  color: #75827a;
  user-select: none;
}

figure.highlight .code {
  width: 99%;
}

.hljs,
.highlight {
  color: #d8e8dd;
  background: var(--code);
}

.hljs-comment,
.hljs-quote {
  color: #819089;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
  color: #f0a6c9;
}

.hljs-number,
.hljs-literal,
.hljs-variable,
.hljs-template-variable,
.hljs-tag .hljs-attr {
  color: #e6b56a;
}

.hljs-string,
.hljs-doctag {
  color: #96d8ae;
}

.hljs-title,
.hljs-section,
.hljs-selector-id {
  color: #8dc8f5;
}

.hljs-type,
.hljs-class .hljs-title {
  color: #d7cf83;
}

.article-prose table {
  display: block;
  overflow-x: auto;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  border-spacing: 0;
}

.article-prose th,
.article-prose td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.article-prose th {
  background: var(--surface-2);
  text-align: left;
}

.article-prose tr:last-child td {
  border-bottom: 0;
}

.article-prose img {
  margin: 1.4rem 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toc-panel {
  position: sticky;
  top: 96px;
  padding: 16px;
}

.toc-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.toc-panel h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.toc-top {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}

#toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

#toc li + li {
  margin-top: 6px;
}

#toc a {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

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

#toc .toc-h3 {
  padding-left: 12px;
}

#toc .toc-h4 {
  padding-left: 24px;
}

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

.article-nav a {
  padding: 18px;
  color: var(--ink);
}

.article-nav span {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.article-nav strong {
  display: block;
  margin-top: 6px;
  line-height: 1.35;
}

.pagination-wrap {
  margin-top: 28px;
}

#page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#page-nav .page-number,
#page-nav .extend,
#page-nav .space {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

#page-nav .current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #103225;
}

.links-content {
  display: grid;
  gap: 16px;
}

.links-content .section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.links-content .title {
  margin: 0;
  color: var(--ink);
}

.links-content .card {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}

.links-content .card:hover {
  border-color: var(--accent);
  background: #f7faf8;
}

.links-content .ava {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
}

.links-content .card-header {
  display: grid;
  gap: 3px;
  min-width: 0;
  line-height: 1.35;
}

.links-content .card-header strong {
  color: var(--accent);
}

.links-content .info {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: #171a18;
  color: #bdc9c1;
}

.site-footer__inner {
  padding: 28px 0 34px;
}

.site-footer p {
  margin: 0;
}

.site-footer p + p {
  margin-top: 8px;
}

.site-footer a {
  color: #9ce0bd;
}

@media (max-width: 980px) {
  .home-hero,
  .layout-grid,
  .article-grid {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .toc-panel {
    position: static;
  }

  .home-terminal {
    max-width: 560px;
  }

  .article-nav,
  .directory-grid,
  .links-content .section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .site-header__inner,
  .site-main,
  .site-footer__inner,
  .article-main {
    width: min(100% - 30px, 1180px);
  }

  .site-header__inner {
    flex-wrap: wrap;
    min-height: 66px;
  }

  .site-brand__text small {
    max-width: 210px;
  }

  .menu-toggle {
    display: block;
  }

  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    margin-left: 0;
    padding-bottom: 14px;
  }

  .site-nav.is-open {
    display: flex;
  }

  .site-nav__link {
    width: 100%;
  }

  .home-hero,
  .page-hero,
  .article-header {
    padding: 24px;
  }

  .home-hero {
    min-height: 0;
  }

  .home-hero h1 {
    font-size: 2.28rem;
  }

  .page-hero h1,
  .article-header h1 {
    font-size: 2rem;
  }

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

  .section-head {
    display: block;
  }

  .post-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .post-card__date {
    padding-top: 0;
  }

  .featured-post,
  .content-panel,
  .empty-state,
  .archive-year,
  .article-body {
    padding: 22px;
  }
}

@media (max-width: 460px) {
  .site-brand__text small {
    display: none;
  }

  .metric-strip {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    display: grid;
  }
}
