: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);
  animation: pulse 3.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 4px rgba(62, 106, 76, 0.1);
  }
  50% {
    box-shadow: 0 0 0 9px rgba(62, 106, 76, 0);
  }
}

.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: 0;
}

/* 星空面板：四个页面共用，尺寸一致 */
.sky {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 460px;
  margin: clamp(8px, 1.2vw, 14px);
  padding: clamp(1.6rem, 4vw, 2.6rem) 0;
  border: 1px solid rgba(62, 106, 76, 0.35);
  border-radius: 16px;
  background: #060d0c;
  color: #eff5f0;
}

.hero__stars {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.sky > .wrap {
  position: relative;
  z-index: 3;
  width: 100%;
}

.sky > .wrap h1 {
  color: #f3f8f4;
}

.sky > .wrap p {
  color: rgba(209, 224, 214, 0.85);
}

.hero h1 {
  margin: 0;
  color: #f3f8f4;
  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: 18em;
  text-wrap: balance;
}

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

.hero .lede {
  color: rgba(209, 224, 214, 0.85);
}

.hero h1,
.lede {
  animation: rise 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.lede {
  animation-delay: 0.16s;
}

.hero__contour {
  position: relative;
  z-index: 2;
  margin-top: auto;
  padding-top: clamp(1.2rem, 3vw, 2rem);
  width: 100%;
  height: clamp(80px, 12vw, 150px);
  animation: sway 9s ease-in-out 2.8s infinite;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes sway {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.hero__contour path {
  fill: none;
  stroke: rgba(207, 228, 214, 0.3);
  stroke-width: 1;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.hero__contour path.relief {
  stroke: #86b79a;
  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;
  animation: rise 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) 0.24s both;
}

.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);
}

.section .rows > li {
  animation: rise 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.section .rows > li:nth-child(1) {
  animation-delay: 0.3s;
}

.section .rows > li:nth-child(2) {
  animation-delay: 0.38s;
}

.section .rows > li:nth-child(3) {
  animation-delay: 0.46s;
}

.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, transform 0.2s ease;
}

a.row:hover {
  background: var(--sage-soft);
  transform: translateX(3px);
}

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);
  animation: rise 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) 0.42s both;
}

.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,
    transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  background: var(--green-deep);
  border-color: var(--green-deep);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(43, 76, 54, 0.16);
}

.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);
}

/* 内页页头：与首页一致的星空面板 */
.page-head--star {
  padding: 0;
}

/* 内页等高线贴底，标题保持垂直居中 */
.page-head--star .hero__contour {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
}

.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);
}

/* 分类总览卡片 */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1rem;
  padding: clamp(1.4rem, 4vw, 2.2rem) 0;
}

.cat-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem 1.35rem;
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: 4px;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.cat-card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(43, 76, 54, 0.07);
}

.cat-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.cat-card__head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.16rem;
  font-weight: 600;
}

.cat-card__count {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-faint);
  white-space: nowrap;
}

.cat-card__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.cat-card__list a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  border: 0;
  color: var(--ink);
}

.cat-card__list a:hover {
  color: var(--green);
}

.cat-card__date {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  white-space: nowrap;
}

.cat-card__title {
  font-size: 0.94rem;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-card__more {
  margin-top: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
}

/* 分类页筛选器 */

.filter {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1.2rem 0 0;
  max-width: 420px;
}

.filter input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--ink);
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.filter input:focus {
  outline: 2px solid var(--green);
  outline-offset: 1px;
  border-color: var(--green);
}

.filter__count {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-faint);
  white-space: nowrap;
}

.rows li[hidden] {
  display: none;
}

.rows .cat-empty {
  padding: 1.3rem 0;
  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 h1,
  .lede,
  .hero__contour,
  .brand__mark,
  .section__head,
  .section .rows > li,
  .entry {
    animation: none;
  }

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

  a.row:hover,
  .btn:hover {
    transform: none;
  }
}
