:root {
  --bg: #0c0c14;
  --surface: #13131e;
  --border: #1e1e30;
  --text: #d8d8e4;
  --muted: #8888aa;
  --accent: #6c8cff;
  --accent2: #ff6c8c;
  --heading: #e8e8f0;
  --serif: 'Georgia', 'Times New Roman', 'Noto Serif', serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --max-w: 720px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: 18px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--serif);
  background: var(--bg);
  color: var(--text);
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}

/* ── Top nav bar ─────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12,12,20,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.72rem;
}
.topbar a { color: var(--accent); text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.topbar .nav-left { display: flex; align-items: center; gap: 0.75rem; }
.topbar .nav-right { display: flex; align-items: center; gap: 1rem; }
.topbar .part-label {
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  transition: all 0.2s;
}
.pdf-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none !important;
}
.pdf-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* ── Article container ───────────────────────────── */
article {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

/* ── Title block ─────────────────────────────────── */
.paper-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.paper-header h1 {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.3;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}
.paper-header .meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.8;
}
.paper-header .meta .author-name { color: var(--accent); }
.paper-header .tag {
  display: inline-block;
  background: #1a1a2e;
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.65rem;
  margin: 0 2px;
}

/* ── Abstract ────────────────────────────────────── */
.abstract {
  margin: 2rem 0;
  padding: 1.5rem 1.75rem;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
  line-height: 1.8;
}
.abstract-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  display: block;
}

/* ── Headings ────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--heading);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}
h1 {
  font-size: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; color: var(--muted); }
h4 { font-size: 0.95rem; color: var(--muted); font-style: italic; }

/* ── Paragraphs and text ─────────────────────────── */
p { margin-bottom: 1.1rem; }

strong { color: var(--heading); }
em { color: #c0c0d8; }

/* ── Math ────────────────────────────────────────── */
.math.display {
  overflow-x: auto;
  padding: 1rem 0;
  margin: 0.5rem 0;
}
mjx-container[jax="CHTML"][display="true"] {
  margin: 1rem 0 !important;
  overflow-x: auto;
}

/* ── Lists ───────────────────────────────────────── */
ul, ol {
  margin: 0.75rem 0 1rem 1.5rem;
}
li { margin-bottom: 0.4rem; }

/* ── Tables ──────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.85rem;
  overflow-x: auto;
  display: block;
}
thead th {
  background: var(--surface);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
}
td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:hover td { background: rgba(108,140,255,0.03); }

/* ── Theorem / Definition / Proof blocks ─────────── */
.theorem, .definition, .lemma, .proposition, .corollary, .conjecture, .axiom, .remark, .example {
  margin: 1.5rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.theorem { border-left: 3px solid var(--accent); }
.definition { border-left: 3px solid #8c6cff; }
.proposition { border-left: 3px solid #6cffb8; }
.corollary { border-left: 3px solid #ffb86c; }
.axiom { border-left: 3px solid var(--accent2); }
.proof {
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.5rem;
  border-left: 2px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}
.proof em:first-child {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Code blocks ─────────────────────────────────── */
pre, code {
  font-family: var(--mono);
  font-size: 0.82rem;
}
code {
  background: var(--surface);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: #c0c0e0;
}
pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1rem 0;
  line-height: 1.5;
}
pre code { background: none; padding: 0; }

/* ── Blockquotes ─────────────────────────────────── */
blockquote {
  border-left: 3px solid var(--border);
  padding: 0.5rem 1.25rem;
  margin: 1rem 0;
  color: var(--muted);
  font-style: italic;
}

/* ── Links ───────────────────────────────────────── */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── References ──────────────────────────────────── */
.references {
  font-size: 0.82rem;
  line-height: 1.7;
}
.references p { margin-bottom: 0.5rem; }

/* ── Table of Contents ───────────────────────────── */
nav#TOC {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
nav#TOC ul { list-style: none; margin-left: 0; }
nav#TOC > ul > li { margin-bottom: 0.3rem; }
nav#TOC ul ul { margin-left: 1.25rem; margin-top: 0.15rem; }
nav#TOC a {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
}
nav#TOC a:hover { color: var(--accent); }

/* ── Footnotes ───────────────────────────────────── */
.footnotes { font-size: 0.82rem; color: var(--muted); margin-top: 3rem; border-top: 1px solid var(--border); padding-top: 1rem; }

/* ── Paper footer ────────────────────────────────── */
.paper-footer {
  text-align: center;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}
.paper-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
}
.paper-nav a {
  flex: 1;
  display: block;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  text-align: center;
  transition: border-color 0.2s;
}
.paper-nav a:hover { border-color: var(--accent); text-decoration: none; }
.paper-nav .label { display: block; font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.25rem; }

/* ── Mobile responsiveness ───────────────────────── */
@media (max-width: 600px) {
  html { font-size: 16px; }
  article { padding: 2rem 1rem 4rem; }
  .paper-header h1 { font-size: 1.4rem; }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }
  .math.display { font-size: 0.85rem; }
  .topbar { padding: 0.5rem 1rem; }
  .paper-nav { flex-direction: column; }
  table { font-size: 0.75rem; }
  .theorem, .definition, .proposition, .corollary, .axiom, .proof, .abstract {
    padding: 1rem;
  }
}

@media (max-width: 400px) {
  html { font-size: 15px; }
  .paper-header h1 { font-size: 1.2rem; }
}

/* ── Print ───────────────────────────────────────── */
@media print {
  body { background: white; color: black; }
  .topbar { display: none; }
  article { max-width: 100%; padding: 0; }
  .theorem, .definition, .proposition, .corollary, .abstract { border: 1px solid #ccc; background: #f8f8f8; }
}
