body {
  background-color: #fcf9f2; /* Aged cream paper */
  color: #333;
  /* Courier Prime (Mono) ensures 2 chars = 1 CJK char width for alignment */
  font-family: "Courier Prime", "Noto Serif SC", serif;
  line-height: 1.8;
  max-width: 900px;
  margin: 2em auto;
  padding: 4em 5em;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  border: 1px solid #e2decb;
  position: relative;
  text-rendering: geometricPrecision;
}

/* Mobile responsive */
@media (max-width: 768px) {
  body {
    margin: 0;
    padding: 1.5em 1em;
    border: none;
    box-shadow: none;
  }

  h1 {
    font-size: 1.8em;
  }

  .meta {
    font-size: 0.8em;
  }

  .meta span {
    margin: 0 0.5em;
    display: inline-block;
  }
}
/* Subtle paper texture effect */
body::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url('paper-fibers.png');
  opacity: 0.2;
  pointer-events: none;
  z-index: -1;
}
.frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  font-family: "Courier Prime", serif;
  line-height: 1.2;
}
.frac .numer { border-bottom: 1.5px solid #444; padding: 0 .2em; }
.frac .denom { padding: 0 .2em; }
.sqrt {
  display: inline-block;
  position: relative;
  padding-left: 0.1em;
  padding-right: 0.2em;
  margin-left: 0.7em;
}
.sqrt::before {
  content: "\221A";
  position: absolute;
  left: -0.7em;
  top: 0;
}
.sqrt::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-top: 1.2px solid currentColor;
}
.matrix {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  border-left: 1.5px solid #444;
  border-right: 1.5px solid #444;
  padding: 0 .3em;
}
.matrix .matrix-row { display: block; }
.op-limits {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
}
.op-limits .op-upper { font-size: 0.7em; order: -1; }
.op-limits .op-sym { font-size: 1.4em; line-height: 1; }
.op-limits .op-lower { font-size: 0.7em; }
.boxed {
  border: 1px solid #444;
  padding: 0 .2em;
  display: inline-block;
}
.dbref { color: #2563eb; text-decoration: underline dotted; cursor: pointer; }
.img-ref { color: #854; font-style: italic; }
table.layout { border-collapse: collapse; margin: 0.5em 0; }
table.layout td { border: none; padding: 4px 8px; }
table {
  border-collapse: collapse;
  margin: 2em auto;
  width: 95%;
  background-color: rgba(255,255,255,0.4);
  /* Tables often rely on the 2:1 ratio for internal alignment */
  font-family: "Courier Prime", "Noto Serif SC", serif;
}
td, th {
  border: 1px solid #c2bead;
  padding: 8px 12px;
  vertical-align: top;
}
/* Equation tables: inline fraction/equation layout */
table.eq {
  display: inline-table;
  border-collapse: collapse;
  border-spacing: 0;
  margin: 0;
  padding: 0;
  width: auto;
  vertical-align: middle;
  background: none;
  border: none;
  box-shadow: none;
  font-size: inherit;
}
table.eq td {
  border: none;
  padding: 0 2px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  line-height: 1;
  font-size: inherit;
}
table.eq td.numer {
  border-bottom: 1.5px solid #444;
  padding: 0 0.2em;
}
table.eq td.denom {
  padding: 0 0.2em;
}
.meta {
  color: #854;
  font-size: 0.9em;
  margin-bottom: 1.5em;
  border-top: 1px solid #dcd8c5;
  border-bottom: 1px solid #dcd8c5;
  padding: 0.6em 0;
  text-align: center;
  letter-spacing: 0.05em;
  font-family: "Noto Serif SC", serif;
}
.meta span { margin: 0 1.2em; }
.meta a:hover {
  color: #2563eb;
  text-decoration: underline;
}
h1 {
  font-family: "Noto Sans SC", sans-serif;
  font-weight: 700;
  font-size: 2.4em;
  margin-top: 0;
  margin-bottom: 0.4em;
  text-align: center;
  color: #111;
  letter-spacing: -0.02em;
}
.article-content {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 1.15em;
  text-align: justify;
  /* Ensure spaces are exactly 0.5em for layouting */
  font-variant-ligatures: none;
}
/* Inline images within article content */
.article-content figure {
  text-align: center;
  margin: 1.5em auto;
  max-width: 80%;
}
.article-content img {
  max-width: 100%;
  height: auto;
  border: 1px solid #c2bead;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.article-content figcaption {
  font-size: 0.85em;
  color: #854;
  margin-top: 0.5em;
  font-family: "Noto Serif SC", serif;
}
/* Image zoom link in figcaption */
.img-zoom {
  font-size: 0.85em;
  color: #2563eb;
  text-decoration: none;
  margin-left: 0.5em;
  cursor: pointer;
  white-space: nowrap;
}
.img-zoom:hover { text-decoration: underline; }
/* Lightbox overlay */
.lightbox-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  cursor: zoom-out;
  justify-content: center;
  align-items: center;
}
.lightbox-overlay.active { display: flex; }
.lightbox-overlay img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border: none;
  box-shadow: 0 4px 30px rgba(0,0,0,0.5);
}
.lightbox-close {
  position: fixed;
  top: 16px; right: 24px;
  color: #fff;
  font-size: 2em;
  cursor: pointer;
  z-index: 10000;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.article-images {
  margin-top: 3em;
  border-top: 1px solid #dcd8c5;
  padding-top: 1.5em;
}
.article-images figure {
  text-align: center;
  margin: 1.5em 0;
}
.article-images img {
  max-width: 100%;
  height: auto;
  border: 1px solid #e2decb;
}
.article-images figcaption {
  font-size: 0.85em;
  color: #854;
  margin-top: 0.3em;
  font-family: "Noto Serif SC", serif;
}
/* Index/TOC pages */
section h2 {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 1.8em;
  margin-bottom: 1em;
  color: #111;
  border-bottom: 2px solid #dcd8c5;
  padding-bottom: 0.5em;
}
section h3 {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 1.2em;
  margin-bottom: 0.5em;
}
.toc-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Noto Serif SC", serif;
}
.toc-table thead tr {
  background: rgba(0,0,0,0.05);
}
.toc-table th {
  text-align: left;
  padding: 8px;
  border-bottom: 2px solid #c2bead;
  font-family: "Noto Sans SC", sans-serif;
}
.toc-table td {
  padding: 8px;
  border-bottom: 1px solid #e2decb;
}
.toc-table a {
  color: #2563eb;
  text-decoration: none;
}
.toc-table a:hover {
  text-decoration: underline;
}
/* Footer disclaimer */
footer {
  margin-top: 4em;
  padding-top: 2em;
  border-top: 1px solid #dcd8c5;
  text-align: center;
  font-size: 0.85em;
  color: #666;
  font-family: "Noto Serif SC", serif;
}
footer p {
  margin: 0.5em 0;
}
/* Back-link to home */
.back-link {
  text-align: center;
  margin-bottom: 1em;
}
.back-link a {
  color: #666;
  text-decoration: none;
  font-size: 0.9em;
}
.back-link a:hover {
  color: #2563eb;
  text-decoration: underline;
}
/* Index page layout */
.index-container {
  max-width: 1200px;
  margin: 0 auto;
}
/* Alphabetical index sections */
.alpha-section {
  margin-bottom: 2em;
}
.alpha-section h3 {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 1.3em;
  color: #111;
  border-bottom: 1px solid #dcd8c5;
  padding-bottom: 0.3em;
  margin-bottom: 0.5em;
}
/* Multi-column author list */
.author-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.5em;
  margin-bottom: 2em;
}
.author-item {
  display: flex;
  justify-content: space-between;
  padding: 0.3em 0.5em;
  border-bottom: 1px dotted #dcd8c5;
}
.author-item a {
  color: #2563eb;
  text-decoration: none;
}
.author-item a:hover {
  text-decoration: underline;
}
.author-item .count {
  color: #666;
  font-size: 0.9em;
  margin-left: 1em;
}
/* Quick jump navigation */
.alpha-nav {
  text-align: center;
  margin: 2em 0;
  padding: 1em;
  background: rgba(255,255,255,0.3);
  border: 1px solid #dcd8c5;
}
.alpha-nav a {
  display: inline-block;
  padding: 0.3em 0.6em;
  margin: 0.2em;
  color: #2563eb;
  text-decoration: none;
  border-radius: 3px;
}
.alpha-nav a:hover {
  background: rgba(37,99,235,0.1);
  text-decoration: underline;
}
.text-center {
  text-align: center;
  width: 100px;
}
/* Common layout container */
.content-container {
  max-width: 1200px;
  margin: 0 auto;
}
/* Year section headers in category/author pages */
.year-section {
  margin-bottom: 3em;
}
.year-section h2 {
  font-family: "Noto Sans SC", sans-serif;
  font-size: 1.5em;
  margin-bottom: 1em;
  color: #111;
  border-bottom: 1px solid #dcd8c5;
  padding-bottom: 0.5em;
}
.year-section h2 .count {
  font-size: 0.8em;
  color: #666;
  font-weight: normal;
}
/* Table column styling */
.col-narrow {
  width: 80px;
  text-align: center;
}
.col-medium {
  width: 120px;
}
.col-wide {
  width: 150px;
}
.col-page {
  width: 60px;
  text-align: center;
}
.text-muted {
  font-size: 0.9em;
  color: #666;
}
.link-muted {
  color: #666;
  text-decoration: none;
}
.link-muted:hover {
  color: #2563eb;
  text-decoration: underline;
}
/* Issue grid */
.issue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1em;
  margin: 2em 0;
}
.issue-card {
  display: block;
  padding: 1em;
  border: 1px solid #dcd8c5;
  background: rgba(255,255,255,0.3);
  text-decoration: none;
  color: #111;
  text-align: center;
  transition: background 0.2s;
}
.issue-card:hover {
  background: rgba(255,255,255,0.6);
}
.issue-card .issue-number {
  font-size: 1.2em;
  font-weight: bold;
  font-family: "Noto Sans SC", sans-serif;
}
.issue-card .issue-count {
  font-size: 0.9em;
  color: #666;
  margin-top: 0.3em;
}
/* Quick links section */
.quick-links {
  margin-top: 2em;
  padding: 1em;
  background: rgba(255,255,255,0.3);
  border: 1px solid #dcd8c5;
  text-align: center;
}
.quick-links a {
  display: inline-block;
  padding: 0.5em 1em;
  margin: 0.5em;
  color: #2563eb;
  text-decoration: none;
  border: 1px solid #dcd8c5;
  border-radius: 4px;
  background: rgba(255,255,255,0.5);
}
.quick-links a:hover {
  background: rgba(37,99,235,0.1);
  text-decoration: underline;
}

/* Mobile table responsiveness */
@media (max-width: 768px) {
  .toc-table {
    font-size: 0.85em;
  }

  .toc-table th,
  .toc-table td {
    padding: 6px 4px;
  }

  .col-narrow,
  .col-medium,
  .col-wide,
  .col-page {
    width: auto;
  }

  /* Hide less important columns on mobile */
  .toc-table .col-page,
  .toc-table .col-narrow {
    display: none;
  }

  .content-container {
    padding: 0;
  }

  .issue-grid,
  .author-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5em;
  }

  .issue-card {
    padding: 0.8em 0.5em;
  }

  .alpha-nav {
    padding: 0.5em;
  }

  .alpha-nav a {
    padding: 0.2em 0.4em;
    font-size: 0.9em;
  }

  .year-section h2 {
    font-size: 1.2em;
  }

  /* Make article content more readable on mobile */
  .article-content {
    font-size: 1em;
    word-break: normal;
  }

  .article-content table {
    font-size: 0.8em;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .article-content img {
    max-width: 100%;
    height: auto;
  }
}
