:root {
  --p32-ink: #17201f;
  --p32-muted: #5c6967;
  --p32-line: #d6dfdc;
  --p32-paper: #fffefa;
  --p32-teal: #176f66;
  --p32-teal-dark: #0c4d47;
  --p32-teal-soft: #e5f3f0;
  --p32-gold: #9a6411;
  --p32-gold-soft: #fff4d9;
  --p32-violet: #6554a6;
  --p32-violet-soft: #f0edfb;
  --p32-danger: #9d451f;
  --p32-danger-soft: #fff0e7;
}

html {
  scroll-behavior: smooth;
}

body.p32-page {
  background: #f4f7f5;
  color: var(--p32-ink);
}

.p32-page .topbar {
  border-color: var(--p32-line);
}

.p32-page .mark {
  border-color: var(--p32-teal);
  color: var(--p32-teal-dark);
}

.p32-page .nav-links {
  overflow-x: auto;
  scrollbar-width: thin;
}

.p32-page .nav-links a {
  white-space: nowrap;
}

.paper-body {
  width: min(1060px, calc(100% - 36px));
  margin: 0 auto;
  padding: 2.5rem 0 4.5rem;
}

.paper-body.reader {
  width: min(840px, calc(100% - 36px));
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(290px, 0.75fr);
  gap: 1.4rem;
  align-items: stretch;
  margin-bottom: 1.4rem;
}

.hero-copy,
.hero-formula,
.reader-card,
.theorem-card,
.view-card,
.content-panel {
  border: 1px solid var(--p32-line);
  border-radius: 16px;
  background: var(--p32-paper);
}

.hero-copy {
  padding: clamp(1.35rem, 3vw, 2.15rem);
}

.hero-formula {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 1.4rem;
  border-color: #b7d6d0;
  background: var(--p32-teal-soft);
}

.eyebrow {
  margin: 0 0 0.55rem;
  color: var(--p32-teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.paper-body h1 {
  max-width: 800px;
  margin: 0 0 0.75rem;
  color: #101817;
  font-size: clamp(1.85rem, 5vw, 3.15rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.paper-body.reader h1 {
  font-size: clamp(1.75rem, 5vw, 2.55rem);
  line-height: 1.2;
}

.paper-body h2 {
  margin: 2.8rem 0 0.85rem;
  padding-bottom: 0.42rem;
  border-bottom: 2px solid #dce7e4;
  color: #14201e;
  font-size: 1.38rem;
  line-height: 1.3;
}

.paper-body h3 {
  margin: 1.6rem 0 0.45rem;
  font-size: 1.08rem;
}

.paper-body p,
.paper-body li,
.paper-body td,
.paper-body th {
  line-height: 1.78;
}

.paper-body p,
.paper-body li {
  color: #263230;
}

.paper-body ul,
.paper-body ol {
  margin: 0.6rem 0 1rem 1.4rem;
  padding: 0;
}

.lead {
  max-width: 760px;
  margin: 0;
  color: #334440;
  font-size: 1.06rem;
  line-height: 1.75;
}

.meta {
  color: var(--p32-muted);
  font-size: 0.9rem;
}

.status-row,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 780;
}

.tag-theory { background: var(--p32-violet-soft); color: #4c3b8a; }
.tag-factual { background: var(--p32-teal-soft); color: var(--p32-teal-dark); }
.tag-none { background: var(--p32-gold-soft); color: #7b4e09; }
.tag-review { background: var(--p32-danger-soft); color: var(--p32-danger); }

.formula-label {
  margin: 0 0 0.55rem;
  color: var(--p32-teal-dark);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.formula-note {
  margin: 0.65rem 0 0;
  color: #3f5651;
  font-size: 0.86rem;
  line-height: 1.55;
}

.boundary {
  margin: 1.4rem 0;
  padding: 1rem 1.15rem;
  border: 1px solid #e8be83;
  border-left: 5px solid var(--p32-gold);
  border-radius: 10px;
  background: #fff9eb;
}

.boundary.danger {
  border-color: #ebbaa4;
  border-left-color: var(--p32-danger);
  background: var(--p32-danger-soft);
}

.boundary p {
  margin: 0.4rem 0 0;
}

.reader-grid,
.theorem-grid,
.view-grid {
  display: grid;
  gap: 0.85rem;
  margin: 1.15rem 0;
}

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

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

.reader-card {
  display: flex;
  min-height: 164px;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 1.05rem;
  color: var(--p32-ink);
  text-decoration: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.reader-card:hover,
.reader-card:focus-visible {
  border-color: #77b3aa;
  box-shadow: 0 12px 28px rgba(23, 59, 54, 0.1);
  transform: translateY(-2px);
}

.reader-card strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

.reader-card span {
  color: #4b5c59;
  font-size: 0.9rem;
  line-height: 1.58;
}

.reader-card b {
  color: var(--p32-teal-dark);
  font-size: 0.86rem;
}

.artifact-state {
  display: block;
  margin-top: 0.25rem;
  color: #7b6544;
  font-size: 0.74rem;
  font-weight: 650;
}

.flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  gap: 0.55rem;
  align-items: center;
  margin: 1.1rem 0;
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid var(--p32-line);
  border-radius: 14px;
  background: #f9fbfa;
}

.flow-node {
  min-width: 145px;
  padding: 0.85rem;
  border: 1px solid #bdd5d0;
  border-radius: 10px;
  background: #fff;
  text-align: center;
}

.flow-node strong {
  display: block;
  margin-bottom: 0.25rem;
}

.flow-node span {
  color: var(--p32-muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.flow-arrow {
  color: var(--p32-teal);
  font-size: 1.25rem;
  font-weight: 800;
}

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

.theorem-card {
  padding: 1rem;
}

.theorem-card .number {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--p32-violet);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.06em;
}

.theorem-card strong {
  display: block;
  margin-bottom: 0.3rem;
}

.theorem-card p {
  margin: 0;
  color: #53615f;
  font-size: 0.89rem;
}

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

.view-card {
  position: relative;
  min-height: 150px;
  overflow: hidden;
  padding: 1rem;
}

.view-card::after {
  position: absolute;
  right: -12%;
  bottom: 29%;
  width: 122%;
  height: 3px;
  border-radius: 999px;
  background: var(--line-color, var(--p32-teal));
  content: "";
  transform: rotate(var(--line-angle, -8deg));
  transform-origin: center;
}

.view-card:nth-child(2) { --line-color: var(--p32-violet); --line-angle: 5deg; }
.view-card:nth-child(3) { --line-color: var(--p32-gold); --line-angle: 17deg; }

.view-card strong,
.view-card span {
  position: relative;
  z-index: 1;
  display: block;
}

.view-card span {
  margin-top: 0.25rem;
  color: var(--p32-muted);
  font-size: 0.84rem;
}

.content-panel {
  margin: 1rem 0;
  padding: 1.05rem 1.15rem;
}

.content-panel.soft-teal { background: var(--p32-teal-soft); border-color: #b8d9d3; }
.content-panel.soft-violet { background: var(--p32-violet-soft); border-color: #d3ccef; }

.math-block {
  margin: 0.9rem 0;
  padding: 0.8rem 1rem;
  overflow-x: auto;
  border: 1px solid #d7e3e0;
  border-radius: 10px;
  background: #f7faf9;
}

.architecture-figure {
  margin: 1.2rem 0 1.6rem;
}

.architecture-frame {
  overflow-x: auto;
  border: 1px solid var(--p32-line);
  border-radius: 14px;
  background: #fff;
}

.architecture-frame img {
  display: block;
  width: 100%;
  min-width: 820px;
  height: auto;
}

.architecture-figure figcaption {
  margin-top: 0.65rem;
  color: var(--p32-muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

mjx-container[jax="CHTML"][display="true"] {
  max-width: 100%;
  margin: 0.65rem 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.2rem 0;
}

.toc {
  margin: 1.35rem 0;
  padding: 1rem 1.2rem;
  border: 1px solid var(--p32-line);
  border-radius: 12px;
  background: #f8faf9;
}

.toc ol {
  columns: 2;
  margin-bottom: 0;
}

.toc a {
  color: var(--p32-teal-dark);
  text-decoration: none;
}

.action {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  padding: 0.55rem 0.85rem;
  border: 1px solid #92c3bb;
  border-radius: 9px;
  background: var(--p32-teal-soft);
  color: var(--p32-teal-dark);
  font-size: 0.88rem;
  font-weight: 750;
  text-decoration: none;
}

.action.secondary {
  border-color: var(--p32-line);
  background: #fff;
  color: #42514f;
}

.data-table-wrap {
  margin: 1rem 0;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 610px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.7rem;
  border: 1px solid #ccd9d6;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: #eaf2f0;
}

.site-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--p32-line);
  color: var(--p32-muted);
  font-size: 0.82rem;
}

@media (max-width: 820px) {
  .hero,
  .reader-grid,
  .reader-grid.reader-grid-four,
  .theorem-grid,
  .view-grid {
    grid-template-columns: 1fr;
  }

  .reader-card {
    min-height: 0;
  }

  .flow {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }

  .flow-node {
    min-width: 0;
  }

  .flow-arrow {
    transform: rotate(90deg);
    text-align: center;
  }
}

@media (max-width: 620px) {
  .paper-body,
  .paper-body.reader {
    width: min(100% - 24px, 840px);
    padding-top: 1.5rem;
  }

  .p32-page .nav {
    min-height: 56px;
  }

  .p32-page .brand-title {
    display: none;
  }

  .p32-page .nav-links {
    justify-content: flex-start;
  }

  .hero-copy,
  .hero-formula {
    padding: 1.1rem;
  }

  .toc ol {
    columns: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reader-card { transition: none; }
}
