:root {
  color-scheme: light;
  --bg: #fbfbfa;
  --surface: #ffffff;
  --ink: #222222;
  --muted: #666666;
  --subtle: #888888;
  --line: #deded8;
  --accent: #315f7d;
  --focus: #2b74b8;
  --max-width: 920px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

.post-content [id] {
  scroll-margin-top: 6.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.75;
}

body.nav-open {
  overflow: hidden;
}

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

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header,
main,
.site-footer {
  width: min(calc(100% - 40px), var(--max-width));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 251, 250, 0.94);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.82rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 0.94rem;
}

.site-nav a,
.site-nav .contact-text {
  color: var(--muted);
}

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

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  background: var(--ink);
  transition: transform 180ms ease, opacity 180ms ease;
}

.nav-open .nav-toggle span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.nav-open .nav-toggle span:nth-child(2) {
  opacity: 0;
}

.nav-open .nav-toggle span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.hero {
  padding: 76px 0 58px;
  border-bottom: 1px solid var(--line);
}

.section-label {
  margin: 0 0 10px;
  color: var(--subtle);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1,
h2,
h3 {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-weight: 600;
  letter-spacing: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 18px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  line-height: 1.22;
}

h3 {
  margin-bottom: 6px;
  font-size: 1.16rem;
  line-height: 1.38;
}

.intro {
  max-width: 720px;
  margin-bottom: 22px;
  color: var(--muted);
}

.section-copy {
  max-width: 680px;
}

.section-copy p {
  margin-bottom: 14px;
  color: var(--muted);
}

.section-link {
  font-weight: 700;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.profile-links a,
.profile-links .contact-text,
.article-item a,
.archive-list a {
  font-weight: 600;
}

.profile-links .contact-text {
  color: var(--muted);
}

.section {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 44px;
  padding: 52px 0;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  align-self: start;
}

.article-list {
  display: grid;
  gap: 30px;
}

.article-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 24px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--line);
}

.article-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.article-item time,
.archive-list time {
  color: var(--subtle);
  font-variant-numeric: tabular-nums;
}

.article-item p {
  margin-bottom: 10px;
  color: var(--muted);
}

.article-item.is-placeholder {
  opacity: 0.72;
}

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

.tags span,
.tags a {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.tags a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

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

.archive-list a {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.archive-list a:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 0 34px;
  color: var(--muted);
  font-size: 0.94rem;
}

.site-footer p {
  margin: 0;
}

.post {
  max-width: 760px;
  min-width: 0;
  padding: 62px 0;
}

.post-header {
  min-width: 0;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--line);
}

.post-header h1 {
  max-width: 760px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(1.55rem, 2.4vw, 2.2rem);
  font-weight: 680;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.post-meta {
  color: var(--subtle);
  font-size: 0.94rem;
  overflow-wrap: anywhere;
}

.post-content {
  min-width: 0;
  padding-top: 34px;
}

.post-content .lead {
  color: var(--ink);
  font-size: 1.08rem;
}

.post-content h2 {
  margin-top: 36px;
  margin-bottom: 12px;
  font-size: 1.5rem;
}

.post-content p,
.post-content li {
  color: var(--muted);
  overflow-wrap: break-word;
}

.post-content pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f5f5f2;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin: 20px 0;
}

.post-content table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.92rem;
}

.post-content th,
.post-content td {
  padding: 9px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.post-content th {
  color: var(--ink);
  font-weight: 700;
}

.post-content td {
  color: var(--muted);
}

.post-content code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.post-content :not(pre) > code,
.post-content a {
  overflow-wrap: anywhere;
}

.algorithm-table {
  display: grid;
  grid-template-columns: minmax(180px, 0.56fr) minmax(0, 1fr);
  gap: 0;
  max-width: 100%;
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}

.algorithm-table > div {
  min-width: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.algorithm-table > div:nth-child(odd) {
  border-right: 1px solid var(--line);
  color: var(--ink);
}

.algorithm-table > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.code-details {
  margin: 20px 0 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}

.code-details summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--accent);
  font-weight: 700;
}

.code-details pre {
  max-height: 560px;
  margin: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
}

.code-list,
.series-list {
  display: grid;
  gap: 8px;
  padding-left: 1.2rem;
}

.code-list li,
.series-list li {
  padding-left: 2px;
}

.post-content figure {
  max-width: 100%;
  min-width: 0;
  margin: 28px 0;
}

.post-content img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}

.post-content figcaption {
  margin-top: 8px;
  color: var(--subtle);
  font-size: 0.9rem;
  line-height: 1.55;
}

.figure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
  margin: 28px 0;
}

.figure-grid figure {
  margin: 0;
}

.math-block {
  max-width: 100%;
  overflow-x: auto;
  margin: 18px 0;
  padding: 4px 0;
}

.math-block mjx-container[display="true"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.series-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.series-nav a {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 650;
}

.series-nav a:hover {
  background: var(--surface);
  text-decoration: none;
}

.series-footer {
  margin-top: 42px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.series-footer h2 {
  margin-top: 0;
}

.taxonomy-section > div:last-child {
  min-width: 0;
}

.taxonomy-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 34px;
}

.taxonomy-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.taxonomy-chip span:last-child,
.taxonomy-count {
  color: var(--subtle);
  font-size: 0.82rem;
  font-weight: 600;
}

.taxonomy-chip:hover,
.taxonomy-chip.is-active,
.taxonomy-card:hover,
.taxonomy-card.is-active {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.taxonomy-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 36px;
}

.life-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.life-random-portal {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
}

.life-random-button {
  flex: 0 0 auto;
  padding: 10px 15px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.life-random-button:hover {
  background: var(--accent);
  color: var(--surface);
}

.life-random-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.life-random-note {
  margin: 0;
  color: var(--subtle);
  font-size: 0.92rem;
}

.taxonomy-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
}

.life-module-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
}

.life-module-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.taxonomy-card strong {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: 1.08rem;
  line-height: 1.3;
}

.life-module-card strong {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: 1.14rem;
  line-height: 1.3;
}

.article-comments {
  min-height: 300px;
  margin-top: 52px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}

.article-comments .section-heading {
  margin-bottom: 14px;
}

.article-comments-note {
  margin: 0 0 26px;
  color: var(--subtle);
  font-size: 0.92rem;
}

.source-divider {
  overflow-wrap: anywhere;
  color: var(--line);
  line-height: 1;
}

.taxonomy-block {
  margin-top: 38px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.taxonomy-block:first-child {
  margin-top: 0;
}

.taxonomy-block h2 {
  margin-bottom: 10px;
}

.taxonomy-list {
  display: grid;
  gap: 20px;
  margin-top: 18px;
}

.taxonomy-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.taxonomy-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.taxonomy-item time {
  color: var(--subtle);
  font-variant-numeric: tabular-nums;
}

.taxonomy-item p,
.muted-note {
  color: var(--muted);
}

.home-search {
  margin-bottom: 28px;
}

.hero .home-search {
  max-width: 900px;
  margin-top: 28px;
  margin-bottom: 0;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 12px;
}

.search-input,
.search-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
}

.search-input {
  min-width: 0;
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--ink);
}

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

.search-button {
  padding: 8px 16px;
  background: var(--ink);
  color: var(--surface);
  cursor: pointer;
  font-weight: 700;
}

.search-button:hover {
  background: var(--accent);
}

.search-actions {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.search-summary {
  margin: 0;
}

.search-clear {
  font-weight: 700;
}

.search-results-panel {
  margin-bottom: 28px;
}

.post-nav {
  margin-top: 42px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.mind-post .post-content,
.life-post .post-content {
  font-size: 1.02rem;
}

.reflection-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 22px 0 34px;
}

.reflection-note {
  min-width: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.reflection-note h3 {
  margin-bottom: 8px;
}

@media (max-width: 720px) {
  .life-random-portal {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .nav-toggle {
    display: block;
  }

  .site-nav {
    position: fixed;
    inset: 72px 20px auto;
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
  }

  .site-nav a,
  .site-nav .contact-text {
    width: 100%;
    padding: 10px 0;
  }

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

  .section,
  .article-item,
  .taxonomy-item,
  .archive-list a,
  .reflection-map,
  .figure-grid,
  .algorithm-table {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .taxonomy-card-grid {
    grid-template-columns: 1fr;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .search-button {
    width: 100%;
  }

  .search-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .algorithm-table > div:nth-child(odd) {
    border-right: 0;
    border-bottom: 0;
    padding-bottom: 2px;
  }

  .algorithm-table > div:nth-child(even) {
    padding-top: 2px;
  }

  .algorithm-table > div:nth-last-child(2) {
    border-bottom: 0;
  }
}

@media (max-width: 560px) {
  .site-header,
  main,
  .site-footer {
    width: min(calc(100% - 28px), var(--max-width));
  }

  .post {
    padding: 42px 0;
  }

  .post-header {
    padding-bottom: 24px;
  }

  .post-header h1 {
    font-size: clamp(1.45rem, 8vw, 1.8rem);
  }

  .post-content {
    padding-top: 26px;
  }

  .post-content h2 {
    font-size: 1.28rem;
  }

  .post-content pre {
    padding: 12px;
  }

  .math-block,
  .post-content pre {
    margin-right: 0;
    margin-left: 0;
  }

  .brand-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hero {
    padding: 46px 0 42px;
  }

  .section {
    padding: 42px 0;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
.sgf-viewer {
  max-width: 760px;
  margin: 1.5rem auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.sgf-board {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.sgf-controls,
.sgf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-top: 0.9rem;
}

.sgf-controls button,
.sgf-actions button,
.sgf-actions a {
  padding: 0.45rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.sgf-controls button:disabled { opacity: 0.4; cursor: default; }
.sgf-controls input[type="range"] { flex: 1 1 220px; }
.sgf-status { margin: 0.8rem 0 0; font-variant-numeric: tabular-nums; }
.sgf-comment { max-height: 11rem; overflow: auto; white-space: pre-wrap; font-size: 0.9rem; color: var(--muted); }
.sgf-viewer-error canvas, .sgf-viewer-error .sgf-controls { display: none; }
