:root {
  --ink: #1f2227;
  --ink-soft: #363a42;
  --muted: #6a7079;
  --link: #3273dc;
  --line: #e6e6e6;
  --rule: #d9d9d9;
  --code-bg: #f5f5f7;
  --measure: 1060px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  font-size: 15.5px;
}

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: "Inter", "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
em { font-style: italic; }
strong { font-weight: 600; }

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

/* ---------- Hero ---------- */
.hero {
  text-align: left;
  padding: 4rem 0 2.5rem;
}

.hero h1 {
  margin: 0;
  max-width: 20em;
  font-weight: 600;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  line-height: 1.18;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.authors {
  margin: 1.6rem 0 0;
  font-size: 1.18rem;
  color: var(--ink-soft);
}
.authors span { white-space: nowrap; }
.authors span + span::before {
  content: "\00a0\00a0";
}

.institution {
  margin: 0.5rem 0 0;
  font-size: 1.05rem;
  color: var(--muted);
}

.venue {
  margin: 0.85rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.6rem;
  margin-top: 1.8rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #363636;
  color: #fff;
  border-radius: 999px;
  padding: 0.5rem 1.15rem;
  font-size: 0.98rem;
  font-weight: 500;
  transition: background 0.15s;
}
.btn:hover { background: #1f1f1f; text-decoration: none; }
.btn-ico { display: inline-flex; align-items: center; opacity: 0.9; }

/* ---------- Sections ---------- */
section { padding: 2.4rem 0 0; }

h2 {
  margin: 0 0 1.1rem;
  text-align: left;
  font-weight: 600;
  font-size: 1.7rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

p { margin: 0 0 1.1rem; text-align: justify; hyphens: auto; }
section > p,
section > .eq,
.theorem,
.assumptions,
.code-figure,
.references { max-width: var(--measure); margin-left: auto; margin-right: auto; }

/* The abstract is set apart like a paper abstract: ruled, narrower column.
   The "About this work" prelude reuses the same look, sitting right beneath it. */
#abstract {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 2rem 0;
  margin-top: 1rem;
}
#about-this-work {
  border-bottom: 1px solid var(--rule);
  padding: 1.8rem 0;
  margin-top: 0;
}
#abstract h2,
#about-this-work h2 {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.9rem;
}
#abstract p,
#about-this-work p {
  max-width: 62ch;
  margin-left: auto;
  margin-right: auto;
  color: var(--ink-soft);
}

/* Loading / error states + reveal animation */
.content-loading,
.content-error {
  text-align: center;
  color: var(--muted);
  padding: 3rem 0;
}
.content-error { max-width: 36rem; margin: 0 auto; }
.content-error code {
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.08em 0.35em;
  border-radius: 4px;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.55s ease;
  will-change: opacity, transform;
}
.reveal.is-revealed {
  opacity: 1;
  transform: none;
}

/* ---------- Intuition figure + PL surfaces ---------- */
.intuition {
  margin: 1.8rem auto;
  max-width: var(--measure);
}
.intuition > figcaption {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  font-weight: 600;
  color: var(--ink);
}
.intuition-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--link);
  border: 1px solid var(--link);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}
.intuition-note {
  margin: 0.8rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-align: left;
}

.pl-surfaces {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 1rem;
}
.pl-surf { margin: 0; min-width: 0; }
.pl-surf-svg {
  width: 100%;
  height: auto;
  aspect-ratio: 6 / 5;
  display: block;
}
.pl-surf figcaption {
  margin-top: 0.3rem;
  text-align: center;
  line-height: 1.35;
}
.pl-surf figcaption strong {
  display: block;
  font-size: 0.9rem;
  color: var(--ink);
}
.pl-formula {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.pl-tag {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.72rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .pl-surfaces { grid-template-columns: 1fr; }
}

/* ---------- Geometry diagram ---------- */
.geo-svg { width: 100%; height: auto; display: block; }
.geo-band { fill: rgba(50, 115, 220, 0.10); stroke: rgba(50, 115, 220, 0.28); stroke-width: 1; }
.geo-patch { fill: rgba(50, 115, 220, 0.06); stroke: var(--link); stroke-width: 1.3; stroke-dasharray: 5 4; }
.geo-curve { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }
.geo-frame { stroke: var(--link); stroke-width: 1.4; }
.geo-m { fill: var(--ink); }
.geo-x { fill: var(--link); }
.geo-proj { fill: #fff; stroke: var(--ink); stroke-width: 1.6; }
.geo-error { stroke: var(--muted); stroke-width: 1.4; stroke-dasharray: 4 3; }
.geo-fo { overflow: visible; }
.geo-mlabel {
  display: flex;
  align-items: center;
  height: 100%;
  font-size: 12px;
  line-height: 1;
  color: var(--ink-soft);
  white-space: nowrap;
}
.geo-mlabel.geo-big { font-size: 13px; color: var(--muted); }
.geo-mlabel.geo-em { color: var(--link); }
.geo-mlabel.geo-patchlab { color: var(--link); }
.geo-mlabel > span {
  background: rgba(255, 255, 255, 0.85);
  padding: 1px 3px;
  border-radius: 4px;
}

/* ---------- AI section: subsection headings, prompt table & block ---------- */
#content h3 {
  margin: 1.9rem 0 0.6rem;
  font-size: 1.18rem;
  font-weight: 600;
  color: var(--ink);
}
.prompt-table {
  width: 100%;
  max-width: var(--measure);
  border-collapse: collapse;
  table-layout: fixed;
  margin: 1rem 0 1.4rem;
  font-size: 0.86rem;
}
.prompt-table th,
.prompt-table td {
  border: 1px solid var(--line);
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
.prompt-table th { background: var(--code-bg); font-weight: 600; }
.prompt-table td.prompt-text {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
  word-break: normal;
}
.prompt-table td.prompt-text p {
  margin: 0 0 0.55rem;
  text-align: left;
  hyphens: none;
}
.prompt-table td.prompt-text p:last-child { margin-bottom: 0; }

/* ---------- Lean syntax highlighting ---------- */
.code-figure .lean-kw { color: #cf222e; }
.code-figure .lean-ty { color: #0550ae; }
.code-figure .lean-fn { color: #8250df; }
.code-figure .lean-nu { color: #0550ae; }
.code-figure .lean-op { color: #57606a; }
.code-figure .lean-cm { color: #6e7781; font-style: italic; }

.widget-missing {
  display: block;
  margin: 1.2rem auto;
  padding: 0.8rem 1rem;
  border: 1px dashed var(--rule);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Display equations */
.eq {
  text-align: center;
  overflow-x: auto;
  margin: 0.4rem 0 1.4rem;
}

/* ---------- Assumptions ---------- */
.assumptions {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1rem;
  margin: 0 auto 1.4rem;
}
.assumptions dt {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.92rem;
  color: var(--muted);
  padding-top: 0.05rem;
}
.assumptions dd { margin: 0; text-align: justify; }

/* ---------- Theorem ---------- */
.theorem {
  border: 1px solid var(--line);
  border-left: 3px solid #363636;
  border-radius: 6px;
  background: #fafafa;
  padding: 1.25rem 1.5rem 0.4rem;
  margin: 0 auto 1.4rem;
}
.theorem-label {
  font-weight: 600;
  margin-bottom: 0.6rem;
  text-align: left;
}
.theorem .eq { margin-bottom: 1rem; }

/* Inline citations */
.cite {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: help;
  text-decoration: none;
  border-bottom: 1px dotted transparent;
}
.cite:hover { text-decoration: none; border-bottom-color: currentColor; }

/* Citation hover tooltip */
.cite-tip {
  position: absolute;
  z-index: 60;
  max-width: 360px;
  background: #1f2227;
  color: #ececec;
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: 9px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  pointer-events: none;
}
.cite-tip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.cite-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: var(--arrow, 50%);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1f2227;
}
.cite-tip.below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #1f2227;
}
.cite-tip em { font-style: italic; color: #fff; }
.cite-tip a { color: #9cc2ff; }
.cite-tip .ref-key { color: #fff; }

/* ---------- Code figure ---------- */
.code-figure {
  margin: 1.4rem auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.code-figure figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.9rem;
  background: var(--code-bg);
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.code-figure figcaption code { color: var(--ink-soft); }
.code-figure pre {
  margin: 0;
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
  background: #fbfbfc;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  color: #2a2d34;
  tab-size: 2;
}
.code-figure pre code { white-space: pre; }

code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.08em 0.35em;
  border-radius: 4px;
}

/* ---------- References ---------- */
.references {
  list-style: none;
  margin: 0 auto;
  padding-left: 0;
  font-size: 0.76rem;
  line-height: 1.42;
  color: var(--ink-soft);
}
.references li {
  margin-bottom: 0.45rem;
  padding-left: 1.6rem;
  text-indent: -1.6rem;
  text-align: left;
}
.ref-key {
  font-weight: 600;
  color: var(--ink);
}

/* ---------- Footer ---------- */
footer {
  margin-top: 3rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--rule);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
footer p { text-align: center; margin: 0; }

@media (max-width: 560px) {
  body { font-size: 0.95rem; }
  .assumptions { grid-template-columns: 1fr; gap: 0.15rem 0; }
  .assumptions dt { padding-top: 0.5rem; }
  .prompt-table,
  .prompt-table thead,
  .prompt-table tbody,
  .prompt-table tr,
  .prompt-table th,
  .prompt-table td {
    display: block;
    width: 100%;
  }
  .prompt-table th + th,
  .prompt-table td + td {
    border-top: 0;
  }
}
