:root {
  color-scheme: dark;
  --bg: #0b0e10;
  --surface: #12171a;
  --line: #263036;
  --text: #e6ebe8;
  --muted: #92a09d;
  --accent: #a6f56b;
  --kind: var(--accent);
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, ui-monospace, "Microsoft YaHei", monospace;
  --page: 68rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

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

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.8 var(--sans);
  overflow-wrap: anywhere;
  position: relative;
  isolation: isolate;
}

body::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 34rem;
  z-index: -1;
  background-image:
    linear-gradient(color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--line) 55%, transparent) 1px, transparent 1px);
  background-size: 2.5rem 2.5rem;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent);
  mask-image: linear-gradient(to bottom, #000, transparent);
}

a { color: inherit; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
[hidden] { display: none !important; }
h1, h2 { text-wrap: balance; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* 顶栏 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding: 0.75rem max(var(--gutter), calc((100% - var(--page)) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.875rem;
}

.brand { font-weight: 700; text-decoration: none; font-size: 1rem; }
.brand-path { color: var(--accent); }

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  margin-left: 0.2em;
  vertical-align: -0.15em;
  background: var(--accent);
  animation: blink 1.1s steps(2, start) infinite;
}

@keyframes blink { to { visibility: hidden; } }

.site-header nav { display: flex; flex-wrap: wrap; gap: 0 1.1rem; margin-inline: -0.25rem; }

.site-header nav a {
  padding: 0.25rem;
  color: var(--muted);
  text-decoration: none;
}

.site-header nav a:hover { color: var(--text); }
.site-header nav a[aria-current="page"] { color: var(--accent); }
.site-header nav a[aria-current="page"]::before { content: "./"; }

main {
  flex: 1;
  width: 100%;
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin-inline: auto;
  padding: 0 var(--gutter) 4rem;
}

.eyebrow {
  margin: 0 0 0.75rem;
  font: 400 0.875rem/1.5 var(--mono);
  color: var(--accent);
}

/* 首页头部 */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: end;
  padding-block: clamp(3rem, 8vw, 6rem) clamp(2rem, 4vw, 3rem);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6.2vw, 4.25rem);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.hero-intro {
  max-width: 34em;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 1.0625rem;
}

.hero-panel {
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.status { margin: 0 0 1rem; }
.status div { display: grid; grid-template-columns: 3.5em 1fr; gap: 0.5rem; }
.status dt { color: var(--accent); }
.status dt::after { content: ":"; }
.status dd { margin: 0; color: var(--text); font-family: var(--sans); }

.heatmap { margin: 0; }

.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, auto);
  grid-template-columns: repeat(26, 1fr);
  grid-auto-flow: column;
  gap: 2px;
}

.heatmap-grid i { aspect-ratio: 1; border-radius: 1.5px; background: var(--line); }
.heatmap-grid .level-1 { background: color-mix(in srgb, var(--accent) 45%, var(--surface)); }
.heatmap-grid .level-2 { background: color-mix(in srgb, var(--accent) 72%, var(--surface)); }
.heatmap-grid .level-3 { background: var(--accent); }
.heatmap figcaption { margin-top: 0.6rem; color: var(--muted); font-size: 0.75rem; }

/* 最新周报 */
.featured {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.25rem 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--kind);
  border-radius: 6px;
  text-decoration: none;
  transition: border-color 0.15s;
}

.featured:hover { color: inherit; border-color: var(--kind); }
.featured-label { grid-column: 1 / -1; font: 400 0.8125rem/1.6 var(--mono); color: var(--kind); }
.featured strong { font-size: 1.375rem; line-height: 1.4; }
.featured-excerpt { grid-column: 1; color: var(--muted); }
.featured-go { grid-column: 2; grid-row: 2 / span 2; align-self: center; font: 400 0.875rem var(--mono); color: var(--kind); white-space: nowrap; }

/* 内容流 */
.stream { margin-top: clamp(2.5rem, 6vw, 4rem); }

.stream-head h2 { margin: 0 0 0.75rem; font-size: 1.375rem; }

.stream-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chips button {
  min-height: 2.25rem;
  padding: 0 0.8rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font: 400 0.8125rem var(--mono);
  cursor: pointer;
}

.chips button b { font-weight: 400; opacity: 0.7; }
.chips button:hover { color: var(--text); border-color: var(--muted); }
.chips button[aria-pressed="true"] { color: var(--bg); background: var(--kind); border-color: var(--kind); font-weight: 700; }

.search {
  display: flex;
  align-items: center;
  flex: 0 1 18rem;
  min-height: 2.25rem;
  padding-left: 0.65rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.875rem;
}

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

.search input {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 2.25rem;
  padding: 0 0.6rem;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-family: var(--sans);
}

.search input::placeholder { color: var(--muted); }

.month { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0 1rem; padding-top: 1.5rem; }

.month-label {
  position: sticky;
  top: 4rem;
  align-self: start;
  margin: 0;
  padding-top: 0.15rem;
  font: 700 0.875rem/1.8 var(--mono);
  color: var(--muted);
}

.entries { margin: 0; padding: 0; list-style: none; }

.entry {
  display: grid;
  grid-template-columns: 3.25rem 3.25rem minmax(0, 1fr);
  gap: 0 0.75rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--line);
}

.entry:first-child { padding-top: 0; }

.entry-date {
  font: 400 0.8125rem/1.8rem var(--mono);
  color: var(--muted);
  text-decoration: none;
}

.entry-kind {
  font-size: 0.8125rem;
  line-height: 1.8rem;
  color: var(--kind);
  white-space: nowrap;
}

.entry-title { margin: 0; font-size: 1.125rem; line-height: 1.6; font-weight: 600; }
.entry-title a { text-decoration: none; }
.entry-excerpt { margin: 0.2rem 0 0; color: var(--muted); }

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.8rem;
  margin-top: 0.35rem;
  font: 400 0.75rem/1.8 var(--mono);
  color: var(--muted);
}

.entry-external { color: var(--kind); }

.empty { padding-block: 3rem; color: var(--muted); text-align: center; }

/* 栏目页、文章页 */
.page-head { padding-block: clamp(3rem, 7vw, 5rem) 0; }
.page-head .eyebrow { color: var(--kind); }
.page-head h1 { margin: 0; font-size: clamp(2.25rem, 6vw, 3.5rem); line-height: 1.2; }
.page-head p:not(.eyebrow) { margin: 0.75rem 0 0; color: var(--muted); }
.page-head + .stream { margin-top: 2rem; }

.post { max-width: 44rem; margin-inline: auto; padding-top: clamp(2rem, 6vw, 4rem); }

.back {
  display: inline-block;
  margin-bottom: 1rem;
  font: 400 0.875rem var(--mono);
  color: var(--kind);
  text-decoration: none;
}

.post-head h1 { margin: 0; font-size: clamp(1.875rem, 5vw, 2.75rem); line-height: 1.25; }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  margin-top: 0.75rem;
  font: 400 0.8125rem/1.8 var(--mono);
  color: var(--muted);
}

.post-meta a { color: var(--kind); }
.post-head { padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 2rem; }

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.post-nav a { text-decoration: none; }
.post-nav span { display: block; font: 400 0.75rem/1.8 var(--mono); color: var(--muted); }
.post-nav-older { text-align: right; }

/* 正文 */
.prose { font-size: 1.0625rem; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol { margin-block: 1em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.3em; }
.prose li::marker { color: var(--accent); }
.prose h2 { margin: 2.2em 0 0.7em; font-size: 1.375rem; line-height: 1.4; }
.prose h2::before { content: "## "; color: var(--accent); font-family: var(--mono); font-weight: 400; }
.prose h3 { margin: 1.8em 0 0.5em; font-size: 1.125rem; line-height: 1.5; }
.prose a { color: var(--accent); text-underline-offset: 0.2em; }
.prose img, .prose video { display: block; max-width: 100%; height: auto; border-radius: 4px; }
.prose hr { margin-block: 2.5em; border: 0; border-top: 1px dashed var(--line); }

.prose blockquote {
  margin: 1.5em 0;
  padding-left: 1em;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}

.prose code {
  padding: 0.1em 0.35em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  font: 400 0.875em var(--mono);
}

.prose pre {
  margin-block: 1.5em;
  padding: 1rem;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow-wrap: normal;
}

.prose pre code { padding: 0; background: none; border: 0; }

.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 0.9375rem; }
.prose th, .prose td { padding: 0.45em 0.9em; border: 1px solid var(--line); text-align: left; }
.prose th { background: var(--surface); }

.prose-inline { font-size: 1rem; }
.prose-inline p { margin-block: 0.5em; }

/* 实验室页 */
.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-block: 1em; }

.swatches button {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}

.swatches input[type="color"] {
  width: 2.75rem;
  height: 2.75rem;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}

/* 页脚 */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding: 1.25rem max(var(--gutter), calc((100% - var(--page)) / 2));
  border-top: 1px solid var(--line);
  font: 400 0.75rem/1.8 var(--mono);
  color: var(--muted);
}

@media (max-width: 52rem) {
  .hero { grid-template-columns: minmax(0, 1fr); align-items: start; }
}

@media (max-width: 40rem) {
  .month { grid-template-columns: minmax(0, 1fr); padding-top: 1.25rem; }
  .month-label { position: static; padding-bottom: 0.5rem; }
  .entry { grid-template-columns: auto minmax(0, 1fr); }
  .entry-body { grid-column: 1 / -1; }
  .search { flex-basis: 100%; }
  .featured { grid-template-columns: minmax(0, 1fr); }
  .featured-go { grid-column: 1; grid-row: auto; margin-top: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .featured { transition: none; }
}
