@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/assets/fonts/geist-mono-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/assets/fonts/geist-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #ffffff;
  --bg-elevated: #fafafa;
  --bg-subtle: #f4f4f5;
  --bg-code: #f4f4f5;
  --ink: #0b0b0c;
  --ink-secondary: #3f3f46;
  --ink-muted: #52525b;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --rule: #18181b;
  --accent: #00c048;
  --accent-ink: #007a2e;
  --accent-bg: rgba(0, 192, 72, 0.08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.22);
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", Palatino, Georgia, serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --header-h: 58px;
}

[data-theme="dark"] {
  --bg: #09090b;
  --bg-elevated: #111114;
  --bg-subtle: #18181b;
  --bg-code: #18181b;
  --ink: #f4f4f5;
  --ink-secondary: #d4d4d8;
  --ink-muted: #a1a1aa;
  --border: #2e2e2e;
  --border-strong: #3f3f46;
  --rule: #e4e4e7;
  --accent: #00c048;
  --accent-ink: #00c048;
  --accent-bg: rgba(0, 192, 72, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.65);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.65;
  overflow-x: clip;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 0.2em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

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

/* Header & Progress */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1240px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.wordmark {
  display: block;
  height: 22px;
  width: auto;
}

.wordmark-dark {
  display: none;
}

[data-theme="dark"] .wordmark-light {
  display: none;
}

[data-theme="dark"] .wordmark-dark {
  display: block;
}

.paper-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle,
.pdf-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 7px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--ink);
}

.theme-toggle:hover {
  background: var(--bg-subtle);
}

.pdf-link {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--bg);
}

.pdf-link:hover {
  color: var(--bg);
  opacity: 0.88;
}

.reading-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: transparent;
  pointer-events: none;
}

.reading-progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.06s linear;
}

/* 2-Column Editorial Layout */
.page-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.toc-rail {
  position: sticky;
  top: calc(var(--header-h) + 28px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  padding-right: 10px;
}

.toc-heading {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.toc-list,
.toc-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-list > li {
  margin-bottom: 2px;
}

.toc-sublist {
  padding-left: 12px;
  margin-top: 2px;
  margin-bottom: 4px;
  border-left: 1px solid var(--border);
}

.toc a {
  display: block;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 13px;
  line-height: 1.38;
  color: var(--ink-muted);
  text-decoration: none;
}

.toc a:hover {
  color: var(--ink);
  background: var(--bg-subtle);
}

.toc a.is-active {
  color: var(--accent-ink);
  font-weight: 600;
  background: var(--accent-bg);
}

.mobile-toc {
  display: none;
  margin-bottom: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
}

.mobile-toc summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.mobile-toc summary::-webkit-details-marker {
  display: none;
}

.mobile-toc summary::after {
  content: "+";
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink-muted);
}

.mobile-toc[open] summary::after {
  content: "-";
}

.mobile-toc .toc {
  padding: 0 12px 12px;
}

/* Main Paper Column */
.main-col {
  min-width: 0;
}

.paper {
  max-width: 78ch;
  min-width: 0;
  margin: 0 auto;
}

.paper section,
.paper [id] {
  scroll-margin-top: calc(var(--header-h) + 20px);
}

.paper-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.paper-title {
  margin: 0 0 18px;
  font-family: var(--font-sans);
  font-size: clamp(1.65rem, 2.7vw, 2.25rem);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.028em;
  color: var(--ink);
}

.paper-authors {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.paper-affiliation {
  margin: 2px 0 4px;
  font-size: 14px;
  color: var(--ink-muted);
}

.orcid-link {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
}

/* Abstract & Keywords */
.abstract-box {
  margin: 28px 0 36px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--ink);
  border-radius: 0 8px 8px 0;
  background: var(--bg-elevated);
}

.abstract-box h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}

.abstract-box p,
.abstract-box li {
  font-size: 15px;
  line-height: 1.62;
}

.abstract-contributions {
  margin: 14px 0 14px;
  padding-left: 20px;
}

.abstract-contributions li {
  margin-bottom: 10px;
}

.keywords {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--ink-muted);
}

/* Headings & Prose */
.paper h2 {
  margin: 44px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 1.42rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.28;
}

.paper h2 .sec-num {
  display: inline-block;
  margin-right: 10px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--ink-muted);
}

.paper h3 {
  margin: 30px 0 10px;
  font-size: 1.14rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.paper h4 {
  margin: 22px 0 8px;
  font-size: 1rem;
  font-weight: 650;
}

.paper p {
  margin: 0 0 14px;
  font-family: var(--font-serif);
  font-size: 1.03rem;
  line-height: 1.7;
  color: var(--ink);
}

.paper ul,
.paper ol {
  margin: 0 0 16px;
  padding-left: 24px;
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.68;
}

.paper li {
  margin-bottom: 6px;
}

.paper code,
.paper pre {
  font-family: var(--font-mono);
}

.paper code {
  font-size: 0.87em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-code);
  border: 1px solid var(--border);
}

/* Theorems, Propositions, Proofs */
.theorem,
.proposition {
  margin: 22px 0;
  padding: 16px 20px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--bg-elevated);
}

.theorem-title {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-sans);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink);
}

.theorem p:last-child,
.proposition p:last-child {
  margin-bottom: 0;
}

.proof {
  margin: 18px 0 24px;
  padding: 14px 18px;
  border-left: 2px solid var(--border-strong);
  background: transparent;
}

.proof-title {
  font-family: var(--font-sans);
  font-weight: 650;
  font-style: italic;
}

.qed {
  float: right;
  font-style: normal;
  color: var(--ink-muted);
}

/* Algorithm Cards (Appendix C) */
.algorithm {
  margin: 24px 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.alg-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
}

.alg-meta {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--ink-secondary);
}

.alg-meta p {
  margin: 2px 0;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.5;
}

.alg-lines {
  margin: 0;
  padding: 12px 16px 14px 36px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.62;
  overflow-x: auto;
}

.alg-lines li {
  margin-bottom: 3px;
}

.alg-lines li.indent-1 {
  padding-left: 20px;
}

.alg-lines li.indent-2 {
  padding-left: 40px;
}

.alg-kw {
  font-weight: 700;
  color: var(--ink);
}

.alg-comment {
  color: var(--ink-muted);
  font-style: italic;
}

/* Copyable Constants (Appendix B) */
.const-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-elevated);
}

.const-label {
  flex-shrink: 0;
  font-size: 0.9rem;
  color: var(--ink-secondary);
}

.copyable-const {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.5;
  word-break: break-all;
  color: var(--ink);
}

.copy-btn {
  flex-shrink: 0;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.copy-btn:hover {
  background: var(--bg-subtle);
}

.copy-btn.copied {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-bg);
}

/* Tables */
.table-wrap {
  margin: 24px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.table-caption {
  padding: 12px 16px 8px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.table-wrap thead th {
  padding: 9px 12px;
  text-align: left;
  font-weight: 650;
  color: var(--ink);
  border-bottom: 2px solid var(--rule);
  white-space: nowrap;
  background: var(--bg-elevated);
}

.table-wrap tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table-wrap tbody tr:last-child td {
  border-bottom: none;
}

.table-wrap tbody tr.summary-row td {
  font-weight: 650;
  border-top: 2px solid var(--rule);
  background: var(--bg-elevated);
}

.table-wrap .num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.81rem;
  white-space: nowrap;
}

.table-wrap .mono-cell {
  font-family: var(--font-mono);
  font-size: 0.79rem;
  word-break: break-all;
}

/* Figures & Lightbox */
.paper-figure {
  margin: 28px 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
}

.figure-frame {
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

[data-theme="dark"] .paper-figure .figure-frame {
  background: #ffffff;
  padding: 16px;
  border-radius: 10px;
}

.paper-figure img {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}

.paper-figure img:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.paper-figure figcaption {
  margin-top: 12px;
  font-family: var(--font-sans);
  font-size: 0.87rem;
  line-height: 1.55;
  color: var(--ink-secondary);
}

.lightbox {
  border: none;
  padding: 0;
  max-width: min(94vw, 1200px);
  max-height: 92vh;
  background: transparent;
  margin: auto;
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
}

.lightbox-card {
  position: relative;
  background: #ffffff;
  color: #0b0b0c;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  max-height: 92vh;
  overflow: auto;
}

.lightbox-close {
  position: sticky;
  top: 0;
  float: right;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #d4d4d8;
  background: #ffffff;
  color: #0b0b0c;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-img-wrap img {
  display: block;
  max-width: 100%;
  max-height: 76vh;
  margin: 0 auto;
}

.lightbox-caption {
  margin: 12px 0 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #3f3f46;
}

/* Math Equations */
.katex-display {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.4rem 0;
}

.paper code,
.table-caption code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.paper p,
.paper li,
.table-caption {
  overflow-wrap: break-word;
}

.algorithm {
  overflow-x: auto;
}

.eq-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0;
}

.eq-body {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.eq-num {
  flex-shrink: 0;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink-muted);
}

/* References */
.ref-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

.ref-list li {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.91rem;
  line-height: 1.55;
}

.ref-list li:target {
  background: var(--accent-bg);
}

.ref-key {
  font-family: var(--font-mono);
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink);
}

/* Appendix placeholder */
.appendix-placeholder {
  margin-top: 36px;
  padding: 18px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  color: var(--ink-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  font-size: 13px;
  color: var(--ink-muted);
}

.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* Responsive Breakpoints */
@media (max-width: 960px) {
  .page-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-top: 24px;
  }

  .toc-rail {
    display: none;
  }

  .mobile-toc {
    display: block;
  }
}

@media (max-width: 640px) {
  .header-inner {
    padding: 0 14px;
  }

  .paper-pill {
    display: none;
  }

  .page-shell {
    padding: 18px 14px 56px;
  }

  .abstract-box {
    padding: 16px;
  }

  .ref-list li {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
