/* ── Design tokens ──────────────────────────────────────────── */
:root {
  --bg:          #1b1a17;
  --paper:       #f4efe6;
  --paper-2:     #ece5d6;
  --ink:         #1b1a17;
  --muted:       #6b6760;
  --rule:        rgba(244,239,230,0.1);
  --accent:      #b3502b;
  --pass:        #2f5d3a;
  --pass-bg:     rgba(47,93,58,0.18);
  --pass-fg:     #80b890;
  --fail:        #a8321a;
  --fail-bg:     rgba(168,50,26,0.18);
  --fail-fg:     #e08070;
  --partial:     #8a6500;
  --partial-bg:  rgba(138,101,0,0.18);
  --partial-fg:  #d0aa40;
  --struct-bg:   rgba(45,74,107,0.18);
  --struct-fg:   #80a0c8;
  --radius:      4px;
}

/* ── Reset & base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--paper);
  font-family: "EB Garamond", Georgia, serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-wrap { min-height: 100vh; display: flex; flex-direction: column; }
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px 80px;
  width: 100%;
  flex: 1;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid rgba(244,239,230,0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
}
.nav-brand {
  color: var(--accent);
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.nav-links { display: flex; gap: 28px; align-items: center; }
.nav-link {
  color: rgba(244,239,230,0.45);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color 0.15s;
}
.nav-link:hover { color: var(--paper); text-decoration: none; }
.nav-link--repo { color: var(--accent); }
.nav-link--repo:hover { color: #d06040; }

/* ── Hero ───────────────────────────────────────────────────── */
.hero {
  padding: 72px 0 56px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 56px;
}
.hero-eyebrow {
  display: flex;
  justify-content: space-between;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(244,239,230,0.35);
  margin-bottom: 24px;
}
.hero-title {
  font-size: clamp(32px, 5vw, 60px);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -0.015em;
  color: var(--paper);
  margin-bottom: 16px;
}
.hero-tagline {
  font-size: 20px;
  font-style: italic;
  color: rgba(244,239,230,0.6);
  margin-bottom: 28px;
}
.hero-meta {
  display: flex;
  align-items: center;
  gap: 24px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: rgba(244,239,230,0.4);
}
.hero-link { color: var(--accent); font-size: 11px; }
.hero-link:hover { text-decoration: none; color: #d06040; }

/* ── Sections ───────────────────────────────────────────────── */
.section { margin-bottom: 64px; }
.sec-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}

/* ── Parameters ─────────────────────────────────────────────── */
.param-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.param-table th {
  text-align: left;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244,239,230,0.35);
  padding: 10px 18px;
  background: rgba(244,239,230,0.03);
  border-bottom: 1px solid var(--rule);
}
.param-table td {
  padding: 10px 18px;
  border-bottom: 1px solid rgba(244,239,230,0.05);
  color: rgba(244,239,230,0.85);
  vertical-align: middle;
}
.param-table tr:last-child td { border-bottom: none; }
.param-table tr:hover td { background: rgba(244,239,230,0.025); }
.td-note { color: rgba(244,239,230,0.45) !important; font-size: 14px; }

.pstatus {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 2px;
  white-space: nowrap;
}
.pstatus--locked             { background: rgba(179,80,43,0.18); color: #e89070; }
.pstatus--attractor          { background: var(--pass-bg);  color: var(--pass-fg); }
.pstatus--best-fit           { background: var(--struct-bg); color: var(--struct-fg); }
.pstatus--structural-floor   { background: var(--partial-bg); color: var(--partial-fg); }
.pstatus--inconclusive       { background: rgba(120,120,120,0.18); color: #a8a8a0; }

/* ── Papers ─────────────────────────────────────────────────── */
.papers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 18px;
}
.paper-card {
  background: rgba(244,239,230,0.03);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}
.paper-card:hover {
  background: rgba(244,239,230,0.06);
  border-color: rgba(244,239,230,0.2);
  text-decoration: none;
}
.paper-card--fail { border-left: 3px solid var(--fail); }
.paper-card--pass { border-left: 3px solid var(--pass); }
.paper-head { display: flex; align-items: center; justify-content: space-between; }
.paper-id {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(244,239,230,0.35);
}
.paper-id--link {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}
.paper-id--link:hover { color: #d06040; text-decoration: none; }
.paper-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--paper);
  line-height: 1.3;
}
.paper-summary {
  font-size: 14px;
  color: rgba(244,239,230,0.55);
  line-height: 1.65;
  flex: 1;
}
.paper-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}
.paper-sims {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: rgba(244,239,230,0.3);
}
.paper-link {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--accent);
}
.paper-link:hover { text-decoration: none; color: #d06040; }

.vbadge {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 2px;
  white-space: nowrap;
}
.vbadge--fail    { background: var(--fail-bg);    color: var(--fail-fg); }
.vbadge--pass    { background: var(--pass-bg);    color: var(--pass-fg); }
.vbadge--partial { background: var(--partial-bg); color: var(--partial-fg); }

/* ── Theorems ───────────────────────────────────────────────── */
.theorems-stack { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.theorem-box {
  background: var(--fail-bg);
  border: 1px solid rgba(168,50,26,0.22);
  border-left: 3px solid var(--fail);
  border-radius: var(--radius);
  padding: 18px 22px;
}
.theorem-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fail-fg);
  opacity: 0.85;
  display: block;
  margin-bottom: 6px;
}
.theorem-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--paper);
  line-height: 1.3;
  margin-bottom: 8px;
}
.theorem-body { font-size: 14px; color: rgba(244,239,230,0.6); line-height: 1.65; }

.loophole-box {
  background: var(--pass-bg);
  border: 1px solid rgba(47,93,58,0.25);
  border-left: 3px solid var(--pass);
  border-radius: var(--radius);
  padding: 18px 22px;
}
.loophole-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pass-fg);
  display: block;
  margin-bottom: 8px;
}
.loophole-text { font-size: 14px; color: rgba(244,239,230,0.65); line-height: 1.65; }

/* ── Phases ─────────────────────────────────────────────────── */
.phases-stack { display: flex; flex-direction: column; gap: 10px; }
.phase-block {
  background: rgba(244,239,230,0.025);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.phase-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(244,239,230,0.05);
  cursor: pointer;
  color: inherit;
  text-align: left;
  gap: 16px;
  font-family: inherit;
}
.phase-header:hover { background: rgba(244,239,230,0.03); }
.phase-left { display: flex; flex-direction: column; gap: 3px; }
.phase-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244,239,230,0.35);
}
.phase-title { font-size: 16px; color: var(--paper); font-weight: 500; }
.phase-chevron { color: rgba(244,239,230,0.3); font-size: 14px; flex-shrink: 0; }
.phase-summary {
  padding: 10px 20px;
  font-size: 13px;
  color: rgba(244,239,230,0.45);
  line-height: 1.55;
  border-bottom: 1px solid rgba(244,239,230,0.05);
}
.phase-sims { overflow-x: auto; }

.sim-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.sim-table th {
  text-align: left;
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244,239,230,0.25);
  padding: 8px 20px;
  background: rgba(0,0,0,0.12);
  border-bottom: 1px solid rgba(244,239,230,0.05);
}
.sim-table td {
  padding: 6px 20px;
  border-bottom: 1px solid rgba(244,239,230,0.035);
  vertical-align: top;
}
.sim-table tr:last-child td { border-bottom: none; }
.sim-id     { font-family: "JetBrains Mono", monospace; font-size: 12px; color: rgba(244,239,230,0.4); white-space: nowrap; width: 120px; }
.sim-topic  { color: rgba(244,239,230,0.7); }
.sim-tier   { font-family: "JetBrains Mono", monospace; font-size: 11px; color: rgba(244,239,230,0.3); width: 50px; }
.sim-verdict { font-family: "JetBrains Mono", monospace; font-size: 11px; white-space: nowrap; width: 140px; }
.sim-detail  { font-family: "JetBrains Mono", monospace; font-size: 11px; color: rgba(244,239,230,0.35); }

.sim--pass       .sim-verdict { color: var(--pass-fg); }
.sim--fail       .sim-verdict { color: var(--fail-fg); }
.sim--partial    .sim-verdict { color: var(--partial-fg); }
.sim--structural .sim-verdict { color: var(--struct-fg); }
.sim--deferred   .sim-verdict { color: rgba(244,239,230,0.25); }
.sim--other      .sim-verdict { color: rgba(244,239,230,0.45); }

.sim--pass td { background: rgba(47,93,58,0.04); }
.sim--fail td { background: rgba(168,50,26,0.04); }

.sim--linked { cursor: pointer; }
.sim--linked:hover td { background: rgba(244,239,230,0.06) !important; }
.sim--linked:hover .sim-id { color: var(--accent); }

/* ── Predictions ────────────────────────────────────────────── */
.pred-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.pred-card {
  background: rgba(244,239,230,0.03);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pred-head { display: flex; align-items: center; justify-content: space-between; }
.pred-n { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--accent); letter-spacing: 0.12em; }
.pred-milestone { font-family: "JetBrains Mono", monospace; font-size: 10px; color: rgba(244,239,230,0.3); }
.pred-title { font-size: 16px; color: var(--paper); font-weight: 500; line-height: 1.3; }
.pred-body  { font-size: 13px; color: rgba(244,239,230,0.55); line-height: 1.65; }

/* ── Footer ─────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--rule);
  padding: 24px 32px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: rgba(244,239,230,0.28);
}
.footer-link { color: var(--accent); }
.footer-link:hover { text-decoration: none; }

/* ── Tweaks panel ───────────────────────────────────────────── */
.tweaks-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
}
.tweaks-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #252420;
  border: 1px solid rgba(244,239,230,0.12);
  color: rgba(244,239,230,0.4);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.tweaks-toggle:hover { border-color: var(--accent); color: var(--accent); }
.tweaks-menu {
  position: absolute;
  bottom: 46px;
  right: 0;
  background: #252420;
  border: 1px solid rgba(244,239,230,0.12);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 188px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
}
.tweaks-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(244,239,230,0.3);
  margin-bottom: 10px;
}
.tweaks-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: rgba(244,239,230,0.6);
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}
.tweaks-row:hover { color: rgba(244,239,230,0.85); }
.tweaks-row input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

/* ── Modal overlay ──────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  backdrop-filter: blur(3px);
}
.modal-frame {
  position: relative;
  width: 100%;
  max-width: 1420px;
  height: 90vh;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 32px 96px rgba(0,0,0,0.65);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  background: rgba(27,26,23,0.88);
  border: 1px solid rgba(244,239,230,0.18);
  color: rgba(244,239,230,0.75);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--fail); border-color: var(--fail); color: #fff; }
.modal-iframe { width: 100%; height: 100%; border: none; display: block; }

/* ── Tooltip ────────────────────────────────────────────────── */
.has-tip {
  cursor: help;
  border-bottom: 1px dotted rgba(244,239,230,0.22);
}
.has-tip.has-tip-block { display: block; border-bottom: none; }
.tooltip-bubble {
  position: fixed;
  z-index: 9999;
  max-width: 300px;
  background: #222019;
  border: 1px solid rgba(244,239,230,0.12);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 10px 14px;
  font-family: "EB Garamond", Georgia, serif;
  font-size: 14px;
  line-height: 1.55;
  color: rgba(244,239,230,0.82);
  pointer-events: none;
  box-shadow: 0 6px 28px rgba(0,0,0,0.6);
}

/* ── KaTeX overrides ────────────────────────────────────────── */
.katex { font-size: 1em !important; }

/* ── Table scroll wrapper ───────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.param-table  { min-width: 520px; }
.sim-table    { min-width: 460px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 800px) {
  .main { padding: 0 20px 60px; }
  .navbar { padding: 12px 20px; flex-wrap: wrap; gap: 8px; }
  .nav-links { gap: 14px; flex-wrap: wrap; }
  .hero { padding: 48px 0 40px; }
  .hero-eyebrow { flex-direction: column; gap: 4px; }
  .papers-grid { grid-template-columns: 1fr; }
  .pred-grid { grid-template-columns: 1fr; }
  .footer { flex-direction: column; gap: 8px; text-align: center; }
}

@media (max-width: 480px) {
  .navbar { padding: 10px 16px; }
  .nav-link:not(.nav-link--repo) { display: none; }
  .nav-links { gap: 0; }
  .main { padding: 0 16px 48px; }
  .hero { padding: 36px 0 32px; }
  .hero-tagline { font-size: 17px; }
  .sim-table th, .sim-table td { padding: 6px 12px; }
  .param-table th, .param-table td { padding: 8px 12px; }
}
