:root {
  color-scheme: light;
  --bg: #f6f1e7;
  --bg-soft: #ebe3d4;
  --surface: #fffaf0;
  --surface-strong: #ffffff;
  --ink: #151412;
  --ink-soft: #4c4943;
  --muted: #746f66;
  --line: #d8ceb9;
  --line-strong: #bfb09a;
  --teal: #0b766f;
  --teal-dark: #07524d;
  --cyan: #23a8b8;
  --amber: #b56b16;
  --red: #9d3c2e;
  --shadow: 0 18px 46px rgba(55, 43, 25, 0.12);
  --radius: 8px;
  --content: 1180px;
  --serif: "Iowan Old Style", "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  --sans: "Inter", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151412;
  --bg-soft: #201f1b;
  --surface: #1d1b17;
  --surface-strong: #26231d;
  --ink: #f6efe2;
  --ink-soft: #d8cdbc;
  --muted: #aaa091;
  --line: #40392e;
  --line-strong: #685b49;
  --teal: #38b8aa;
  --teal-dark: #7bd6cd;
  --cyan: #55c8d0;
  --amber: #e1a14d;
  --red: #e06f61;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 9% 12%, rgba(35, 168, 184, 0.13), transparent 25rem),
    linear-gradient(180deg, var(--bg), var(--surface) 34rem, var(--bg));
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.progress {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 100;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(13rem, 1fr) auto minmax(13rem, 1fr);
  align-items: center;
  gap: 1rem;
  min-height: 68px;
  padding: 0.7rem max(1.2rem, calc((100vw - var(--content)) / 2));
  border-bottom: 1px solid rgba(126, 111, 87, 0.22);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  width: fit-content;
  color: var(--ink);
  font-weight: 730;
  text-decoration: none;
}

.brand-mark {
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid var(--teal);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 45%, var(--teal) 45% 55%, transparent 55%),
    linear-gradient(0deg, transparent 45%, var(--amber) 45% 55%, transparent 55%);
}

.nav-links {
  display: inline-flex;
  justify-content: center;
  gap: 1.35rem;
  color: var(--muted);
  font-size: 0.93rem;
}

.nav-links a {
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--teal-dark);
}

.header-actions {
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.55rem;
}

.icon-button,
.text-button,
.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.icon-button {
  width: 2.5rem;
  padding: 0;
}

.text-button,
.secondary-link {
  padding: 0 0.9rem;
  font-size: 0.9rem;
  font-weight: 650;
}

.compact {
  min-height: 2.35rem;
  padding: 0 0.72rem;
}

.primary-link {
  min-width: 9.2rem;
  padding: 0 1.05rem;
  border-color: var(--teal-dark);
  background: var(--teal-dark);
  color: #fffaf0;
  font-weight: 760;
}

.icon-button svg,
.text-button svg,
.primary-link svg,
.secondary-link svg,
.search-field svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon-button:hover,
.text-button:hover,
.primary-link:hover,
.secondary-link:hover,
.icon-button:focus-visible,
.text-button:focus-visible,
.primary-link:focus-visible,
.secondary-link:focus-visible {
  transform: translateY(-1px);
  border-color: var(--teal);
}

.primary-link:hover,
.primary-link:focus-visible {
  background: var(--teal);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(19rem, 0.78fr);
  gap: 2.7rem;
  align-items: center;
  max-width: var(--content);
  min-height: min(620px, calc(100vh - 94px));
  margin: 0 auto;
  padding: 2.6rem 1.25rem 1.8rem;
}

.hero-copy {
  min-width: 0;
}

.hero h1 {
  max-width: 15em;
  margin: 0;
  font-family: var(--serif);
  font-size: 2.62rem;
  line-height: 1.12;
  font-weight: 780;
}

.subtitle {
  margin: 0.82rem 0 0;
  color: var(--teal-dark);
  font-family: var(--serif);
  font-size: 1.55rem;
  line-height: 1.35;
  font-weight: 700;
}

.english-title {
  max-width: 42rem;
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.abstract-panel {
  max-width: 50rem;
  margin-top: 1.45rem;
  padding: 1.2rem 1.25rem;
  border-left: 4px solid var(--teal);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: 0 1px 0 rgba(100, 78, 45, 0.04);
}

.abstract-panel h2 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  color: var(--teal-dark);
}

.abstract-panel p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  max-width: 45rem;
  margin: 1rem 0 0;
}

.meta-grid div {
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.meta-grid dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.meta-grid dd {
  margin: 0.18rem 0 0;
  font-weight: 720;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.15rem;
}

.hero-visual {
  position: relative;
  margin: 0;
}

.hero-visual::before {
  content: "";
  position: absolute;
  inset: auto 6% -7% 6%;
  height: 3rem;
  border-radius: 50%;
  background: rgba(61, 47, 28, 0.16);
  filter: blur(24px);
}

.hero-visual img {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 11;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.signal-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 1.25rem 3.5rem;
}

.signal-strip div {
  min-width: 0;
  padding: 1.2rem 1.2rem 1.15rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.signal-strip div + div {
  border-left: 1px solid var(--line);
}

.signal-strip span {
  display: block;
  color: var(--amber);
  font-size: 0.82rem;
  font-weight: 760;
}

.signal-strip strong {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.45;
}

.system-map {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

.paper-library {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

.paper-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.paper-card {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.paper-card:hover,
.paper-card:focus-visible,
.paper-card.active {
  transform: translateY(-1px);
  border-color: var(--teal);
  background: color-mix(in srgb, var(--surface-strong) 88%, var(--teal) 12%);
}

.paper-card span {
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 790;
}

.paper-card strong {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.35;
}

.paper-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.55;
}

.paper-card small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 680;
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(12rem, 0.38fr) minmax(0, 0.62fr);
  gap: 2rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 2rem;
  line-height: 1.2;
}

.section-heading p {
  margin: 0;
  color: var(--ink-soft);
}

.flow-map {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.7rem;
  align-items: stretch;
}

.flow-node {
  position: relative;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.flow-node::after {
  content: "";
  position: absolute;
  top: 2rem;
  right: -0.72rem;
  z-index: 2;
  width: 0.72rem;
  height: 1px;
  background: var(--line-strong);
}

.flow-node:last-child::after {
  display: none;
}

.flow-node span {
  display: block;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 780;
}

.flow-node strong {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--serif);
  font-size: 1.08rem;
}

.flow-node p {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.reader-shell {
  display: grid;
  grid-template-columns: minmax(12rem, 0.78fr) minmax(0, 3.4fr) minmax(13rem, 0.86fr);
  gap: 1.5rem;
  align-items: start;
  max-width: calc(var(--content) + 7rem);
  margin: 0 auto;
  padding: 1.2rem 1.25rem 5rem;
}

.toc-panel,
.note-panel {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 112px);
  overflow: auto;
  scrollbar-width: thin;
}

.toc-panel {
  padding-right: 0.4rem;
}

.toc-title {
  margin-bottom: 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

#toc {
  display: grid;
  gap: 0.12rem;
}

.toc-link {
  display: block;
  padding: 0.42rem 0.55rem;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  text-decoration: none;
}

.toc-link:hover,
.toc-link:focus-visible,
.toc-link.active {
  border-left-color: var(--teal);
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 64%, transparent);
}

.toc-link.level-3 {
  padding-left: 1.35rem;
  font-size: 0.82rem;
}

.toc-link.level-4 {
  padding-left: 2rem;
  font-size: 0.8rem;
}

.paper {
  min-width: 0;
}

.paper-toolbar {
  position: sticky;
  top: 82px;
  z-index: 12;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}

.search-field {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  height: 2.45rem;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--muted);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.96rem;
}

.search-results {
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.search-results a,
.search-results p {
  display: block;
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  text-decoration: none;
}

.search-results a:first-child,
.search-results p:first-child {
  border-top: 0;
}

.search-results strong {
  color: var(--teal-dark);
}

.paper-content {
  padding: 3rem 3.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 16px 42px rgba(59, 45, 26, 0.07);
}

.paper-content h1,
.paper-content h2,
.paper-content h3,
.paper-content h4 {
  scroll-margin-top: 112px;
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.28;
}

.paper-content h1 {
  margin: 0 0 0.8rem;
  font-size: 2.6rem;
}

.paper-content h2 {
  margin: 3.1rem 0 1rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
  font-size: 2rem;
}

.paper-content h3 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.45rem;
}

.paper-content h4 {
  margin: 1.75rem 0 0.6rem;
  font-size: 1.16rem;
}

.paper-content p,
.paper-content li,
.paper-content blockquote {
  font-family: var(--serif);
  font-size: 1.06rem;
}

.paper-content p {
  margin: 0 0 1.05rem;
  text-align: justify;
}

.paper-content h1 + h2 {
  margin-top: 1.2rem;
  border-top: 0;
}

.paper-content blockquote {
  margin: 1.25rem 0;
  padding: 1rem 1.15rem;
  border-left: 4px solid var(--teal);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: color-mix(in srgb, var(--bg-soft) 55%, transparent);
  color: var(--ink-soft);
}

.paper-content blockquote p:last-child {
  margin-bottom: 0;
}

.paper-content hr {
  height: 1px;
  margin: 2.1rem 0;
  border: 0;
  background: var(--line);
}

.paper-content ul,
.paper-content ol {
  margin: 0 0 1.1rem 1.2rem;
  padding: 0;
}

.paper-content li {
  margin: 0.3rem 0;
  padding-left: 0.2rem;
}

.paper-content strong {
  font-weight: 760;
}

.paper-content em {
  font-style: italic;
}

.paper-content a {
  color: var(--teal-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.paper-content code {
  padding: 0.08rem 0.24rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-soft);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
}

.table-scroll {
  margin: 1.35rem 0 1.55rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.paper-content table {
  width: 100%;
  min-width: 48rem;
  border-collapse: collapse;
  background: var(--surface);
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.55;
}

.paper-content th,
.paper-content td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

.paper-content th:first-child,
.paper-content td:first-child {
  border-left: 0;
}

.paper-content th {
  background: color-mix(in srgb, var(--bg-soft) 72%, transparent);
  color: var(--teal-dark);
  font-weight: 760;
}

.paper-content tr:last-child td {
  border-bottom: 0;
}

.note-panel {
  display: grid;
  gap: 0.9rem;
}

.note-block {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.note-block span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.note-block strong {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.35;
}

.note-block p {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.6;
}

.site-footer {
  max-width: var(--content);
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 1080px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .nav-links {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .hero-visual img {
    max-height: 28rem;
  }

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

  .toc-panel,
  .note-panel {
    position: static;
    max-height: none;
  }

  .toc-panel {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 78%, transparent);
  }

  #toc {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  body {
    font-size: 15px;
  }

  .site-header {
    min-height: 62px;
    padding: 0.55rem 0.9rem;
  }

  .brand span:last-child {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-actions .text-button {
    padding: 0;
    width: 2.5rem;
    font-size: 0;
  }

  .hero {
    padding: 2rem 1rem 1.6rem;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 1.08rem;
  }

  .abstract-panel {
    margin-top: 1rem;
    padding: 0.95rem 1rem;
  }

  .abstract-panel p {
    -webkit-line-clamp: 3;
  }

  .meta-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .meta-grid div {
    padding: 0.65rem 0.55rem;
  }

  .meta-grid dt {
    font-size: 0.74rem;
  }

  .meta-grid dd {
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .signal-strip,
  .paper-grid,
  .section-heading,
  .flow-map,
  .note-panel {
    grid-template-columns: 1fr;
  }

  .signal-strip {
    padding-bottom: 2.5rem;
  }

  .signal-strip div + div {
    border-left: 0;
    border-top: 0;
  }

  .flow-node::after {
    top: auto;
    right: auto;
    bottom: -0.72rem;
    left: 1.2rem;
    width: 1px;
    height: 0.72rem;
  }

  .reader-shell {
    padding: 0.8rem 1rem 4rem;
  }

  #toc {
    grid-template-columns: 1fr;
  }

  .paper-toolbar {
    top: 68px;
    align-items: stretch;
  }

  .paper-content {
    padding: 1.5rem 1.15rem;
  }

  .paper-content h1 {
    font-size: 2rem;
  }

  .paper-content h2 {
    font-size: 1.55rem;
  }

  .paper-content h3 {
    font-size: 1.24rem;
  }

  .paper-content p,
  .paper-content li,
  .paper-content blockquote {
    font-size: 1rem;
    text-align: left;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-strong: #ffffff;
    --ink: #111111;
    --ink-soft: #222222;
    --muted: #555555;
    --line: #cccccc;
  }

  body {
    background: #ffffff;
  }

  .progress,
  .site-header,
  .hero,
  .signal-strip,
  .system-map,
  .toc-panel,
  .note-panel,
  .paper-toolbar,
  .search-results,
  .site-footer {
    display: none !important;
  }

  .reader-shell {
    display: block;
    max-width: none;
    padding: 0;
  }

  .paper-content {
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .paper-content h1,
  .paper-content h2,
  .paper-content h3 {
    break-after: avoid;
  }

  .paper-content p,
  .paper-content li {
    font-size: 11pt;
    line-height: 1.72;
  }
}
