:root {
  --paper: #f4f5ef;
  --paper-raise: #fafbf6;
  --ink: #1f2c25;
  --ink-soft: #5c6b61;
  --ink-faint: #8b978d;
  --line: #d6dcd2;
  --line-soft: #e6eae1;
  --green: #3e6a4c;
  --green-deep: #2b4c36;
  --sage: #e3eadf;
  --sage-soft: #eef1e8;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", STSong,
    "SimSun", serif;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Consolas,
    "Liberation Mono", monospace;

  --wrap: 1080px;
  --measure: 66ch;
  --gap: clamp(1.25rem, 4vw, 2.75rem);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

::selection {
  background: var(--sage);
  color: var(--ink);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--green);
  text-decoration: none;
  border-bottom: 1px solid rgba(62, 106, 76, 0.28);
  transition: border-color 0.2s ease, color 0.2s ease;
}

a:hover {
  border-bottom-color: var(--green);
}

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
  border-radius: 2px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 245, 239, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.84rem;
  letter-spacing: 0.02em;
}

.brand__mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(62, 106, 76, 0.1);
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2.6vw, 2rem);
  font-size: 0.95rem;
}

.nav a {
  position: relative;
  padding: 0.2rem 0;
  border: 0;
  color: var(--ink-soft);
  transition: color 0.15s ease;
}

.nav a:hover {
  color: var(--ink);
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  border-radius: 2px;
  background: transparent;
}

.nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}

.nav a[aria-current="page"]::after {
  background: var(--green);
}

/* ---------- 首页 ---------- */

.hero {
  padding: clamp(2.6rem, 7vw, 5rem) 0 0;
  overflow: hidden;
}

.hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.9rem, 4.8vw, 3rem);
  line-height: 1.34;
  letter-spacing: 0.01em;
  max-width: 22ch;
  text-wrap: balance;
}

.lede {
  margin: 1.15rem 0 0;
  max-width: 44ch;
  color: var(--ink-soft);
}

.hero__contour {
  margin-top: clamp(1.6rem, 4vw, 2.6rem);
  width: 100%;
  height: clamp(96px, 16vw, 200px);
}

.hero__contour path {
  fill: none;
  stroke: #c9d3c4;
  stroke-width: 1;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.hero__contour path.relief {
  stroke: var(--green);
  stroke-width: 1.5;
  stroke-dasharray: 2400;
  stroke-dashoffset: 2400;
  animation: drift 2.6s cubic-bezier(0.5, 0, 0.2, 1) 0.1s forwards;
}

@keyframes drift {
  to {
    stroke-dashoffset: 0;
  }
}

/* ---------- 通用版块 ---------- */

.section {
  padding: clamp(2.2rem, 5vw, 3.4rem) 0;
  border-top: 1px solid var(--line-soft);
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.3rem;
}

.section h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.2rem, 2.6vw, 1.5rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.section__more {
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: nowrap;
  border-bottom-color: transparent;
}

.section__more:hover {
  border-bottom-color: var(--green);
}

/* ---------- 列表 ---------- */

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

.rows > li {
  border-bottom: 1px solid var(--line-soft);
}

.rows > li:first-child {
  border-top: 1px solid var(--line-soft);
}

.row {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 1rem;
  padding: 0.9rem 0;
  border: 0;
  border-radius: 3px;
  color: var(--ink);
  transition: background-color 0.15s ease;
}

a.row:hover {
  background: var(--sage-soft);
}

a.row:hover .row__title {
  color: var(--green);
}

.row__date {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.row__title {
  font-size: 1.01rem;
  line-height: 1.55;
}

.row__tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--green);
  background: var(--sage-soft);
  border-radius: 3px;
  padding: 0.08rem 0.5rem;
  white-space: nowrap;
}

/* ---------- 平台入口 ---------- */

.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem 0 0.2rem;
  border-top: 1px solid var(--line-soft);
}

.entry h3 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 650;
}

.entry p {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  max-width: 50ch;
}

.btn {
  display: inline-block;
  padding: 0.55rem 1.2rem;
  border: 1px solid var(--green);
  border-radius: 3px;
  color: var(--paper-raise);
  background: var(--green);
  font-size: 0.92rem;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--green-deep);
  border-color: var(--green-deep);
}

.btn--ghost {
  background: transparent;
  color: var(--green);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn--ghost:hover {
  background: var(--sage);
  color: var(--green-deep);
}

/* ---------- 页头 ---------- */

.page-head {
  padding-top: clamp(2.4rem, 6vw, 4rem);
  padding-bottom: clamp(1.5rem, 3vw, 2.2rem);
}

.page-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 4.2vw, 2.6rem);
  font-weight: 600;
  line-height: 1.32;
  text-wrap: balance;
}

.page-head p {
  margin: 0.9rem 0 0;
  max-width: 52ch;
  color: var(--ink-soft);
}

.crumbs {
  margin: 0 0 0.9rem;
  font-size: 0.84rem;
  color: var(--ink-faint);
}

.crumbs a {
  border-bottom-color: transparent;
}

.crumbs a:hover {
  border-bottom-color: var(--green);
}

/* ---------- 正文 ---------- */

.prose {
  padding: clamp(1.6rem, 4vw, 2.6rem) 0;
  max-width: var(--measure);
  margin: 0 auto 0 0;
}

.prose h2 {
  margin: 2.4rem 0 0.8rem;
  font-family: var(--serif);
  font-size: 1.28rem;
  font-weight: 600;
  line-height: 1.5;
  text-wrap: balance;
}

.prose h3 {
  margin: 1.8rem 0 0.6rem;
  font-size: 1.05rem;
  font-weight: 650;
}

.prose h2:first-child,
.prose h3:first-child {
  margin-top: 0;
}

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

.prose ul,
.prose ol {
  margin: 0 0 1.05rem;
  padding-left: 1.3rem;
}

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

.prose blockquote {
  margin: 1.2rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 2px solid var(--line);
  color: var(--ink-soft);
}

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

code {
  font-family: var(--mono);
  font-size: 0.87em;
  background: var(--sage-soft);
  border-radius: 2px;
  padding: 0.1em 0.36em;
}

pre {
  margin: 0 0 1.3rem;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  background: var(--paper-raise);
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--green);
  border-radius: 0 3px 3px 0;
  line-height: 1.7;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.86rem;
}

.note {
  margin: 1.2rem 0;
  padding: 0.75rem 1rem;
  background: var(--sage-soft);
  border-left: 2px solid var(--green);
  border-radius: 0 3px 3px 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

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

/* 表格 */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  margin: 0 0 1.3rem;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.8rem 0.55rem 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

th {
  font-weight: 600;
  color: var(--ink-soft);
}

.spec th {
  width: 8rem;
}

.spec td {
  font-family: var(--mono);
  font-size: 0.85rem;
}

/* ---------- 笔记详情 ---------- */

.note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.8rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.note-foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.9rem;
}

.note-foot a {
  border-bottom-color: transparent;
}

.note-foot a:hover {
  border-bottom-color: var(--green);
}

/* ---------- 学习记录索引 ---------- */

.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
}

.cats a {
  font-size: 0.86rem;
  padding: 0.28rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink-soft);
  background: var(--paper-raise);
}

.cats a:hover {
  border-color: var(--green);
  color: var(--green);
}

.cat {
  padding: clamp(1.6rem, 4vw, 2.4rem) 0;
  border-top: 1px solid var(--line-soft);
  scroll-margin-top: 80px;
}

.cat__head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.cat__head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.32rem;
  font-weight: 600;
}

.cat__head span {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-faint);
}

/* ---------- 页脚 ---------- */

.foot {
  border-top: 1px solid var(--line-soft);
  padding: 1.5rem 0 2.4rem;
  color: var(--ink-faint);
  font-size: 0.82rem;
}

.foot__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  justify-content: space-between;
  font-family: var(--mono);
}

/* ---------- 小屏 ---------- */

@media (max-width: 720px) {
  body {
    font-size: 16px;
  }

  .topbar__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding-top: 0.7rem;
    padding-bottom: 0.6rem;
  }

  .nav {
    width: 100%;
    gap: 1.25rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.2rem;
  }

  .row__date {
    order: -1;
  }

  .row__tag {
    justify-self: start;
  }

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

  .entry .btn {
    justify-self: start;
  }

  .spec th,
  .spec td {
    display: block;
    width: auto;
    border-bottom: 0;
    padding: 0.2rem 0;
  }

  .spec tr {
    display: block;
    border-bottom: 1px solid var(--line-soft);
    padding: 0.5rem 0;
  }

  pre {
    padding: 0.75rem 0.8rem;
    font-size: 0.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .hero__contour path.relief {
    stroke-dashoffset: 0;
    animation: none;
  }
}
