@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;700&family=IBM+Plex+Serif:wght@400;600;700&family=JetBrains+Mono:wght@500&display=swap');

:root {
  --bg: #f6f7fb;
  --paper: #ffff;
  --ink: #1a1b22;
  --muted: #5f6375;
  --line: #e0e4f1;
  --primary: #1f2b7b;
  --accent: #2e4de0;
  --accent-soft: #eef2ff;
  --note: #f9fbff;
  --ok: #0f766e;
  --warn: #9a3412;
  --shadow: 0 16px 42px rgba(23, 35, 74, 0.12);
  --radius: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'IBM Plex Serif', serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -8%, #dfe6ff 0%, rgba(223, 230, 255, 0) 45%),
    radial-gradient(circle at 94% 14%, #f0efff 0%, rgba(240, 239, 255, 0) 40%),
    var(--bg);
  line-height: 1.72;
}

.lp-top {
  all: initial;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  padding: 9px 18px;
  background: #0b0b12;
  position: relative;
  z-index: 9999;
  border-bottom: 2px solid #caa14b;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

.lp-brand {
  all: initial;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #f5f2e8;
  text-decoration: none;
  font: 800 13px/1.2 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  letter-spacing: 0.6px;
  cursor: pointer;
}

.lp-dot {
  all: initial;
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #caa14b;
  box-shadow: 0 0 8px #caa14b;
}

.lp-wrap {
  all: initial;
  display: flex;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

.lp-meta {
  all: initial;
  color: #8b8b96;
  font: 500 11px/1.2 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

.lp-link {
  all: initial;
  box-sizing: border-box;
  color: #caa14b;
  text-decoration: none;
  font: 700 11px/1.2 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  border: 1px solid rgba(202, 161, 75, 0.55);
  padding: 5px 11px;
  border-radius: 20px;
  white-space: nowrap;
  cursor: pointer;
}

.shell {
  width: min(1200px, 95vw);
  margin: 22px auto 46px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 22px;
}

.toc {
  position: sticky;
  top: 14px;
  align-self: start;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(34, 48, 98, 0.07);
  font-family: 'IBM Plex Sans', sans-serif;
}

.toc h2 {
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 10px;
  color: var(--primary);
}

.toc ul {
  list-style: none;
  display: grid;
  gap: 6px;
}

.toc-group {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7a8199;
  margin: 14px 0 6px 4px;
  font-weight: 600;
}

.toc-group:first-of-type {
  margin-top: 0;
}

.toc-sub {
  list-style: none;
  display: grid;
  gap: 3px;
  margin: 4px 0 4px 12px;
  padding-left: 8px;
  border-left: 1px dashed var(--line);
}

.toc-sub a {
  font-size: 12px;
  color: #4c5675;
  padding: 3px 8px;
  opacity: 0.9;
}

.toc-sub a:hover {
  opacity: 1;
}

.toc a {
  display: block;
  text-decoration: none;
  color: #2b3356;
  font-size: 13px;
  border-radius: 8px;
  padding: 6px 8px;
  transition: 0.2s ease;
}

.toc a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.paper {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 44px);
}

.paper h1,
.paper h2,
.paper h3,
.paper h4 {
  font-family: 'IBM Plex Sans', sans-serif;
  line-height: 1.28;
  letter-spacing: -0.01em;
}

.title {
  text-align: center;
  margin-bottom: 26px;
}

.title h1 {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  margin-bottom: 10px;
  color: #111433;
}

.meta {
  color: var(--muted);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.95rem;
}

.abstract {
  margin: 24px 0;
  padding: 16px 18px;
  background: linear-gradient(145deg, #f8faff, #f3f6ff);
  border: 1px solid #dfe7ff;
  border-left: 4px solid var(--accent);
  border-radius: 10px;
}

.abstract-title {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 8px;
}

.theorem {
  margin: 24px 0;
  padding: 18px 20px;
  background: linear-gradient(145deg, #fbf9f4, #f6f2e8);
  border: 1px solid #e5dcc5;
  border-left: 4px solid #b58900;
  border-radius: 10px;
}

.theorem-title {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7a5a00;
  margin: 0 0 8px;
  font-weight: 700;
}

.theorem-list {
  margin: 8px 0 10px 22px;
  padding: 0;
}

.theorem-list li {
  margin: 6px 0;
}

.research-status {
  margin: 18px 0 24px;
  padding: 16px 18px;
  border: 1px solid #d8e4db;
  border-left: 4px solid var(--ok);
  border-radius: 10px;
  background: #f7fcf9;
  font-family: 'IBM Plex Sans', sans-serif;
}

.research-status h2 {
  margin: 0 0 7px;
  border: 0;
  padding: 0;
  font-size: 1rem;
  color: #075f58;
}

.research-status p {
  margin: 0;
  font-size: 0.94rem;
  text-align: left;
}

.research-status a,
.references a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

p {
  text-align: justify;
  margin-bottom: 13px;
  font-size: 1.02rem;
}

.keywords {
  font-family: 'IBM Plex Sans', sans-serif;
  color: #3c4268;
  font-size: 0.92rem;
  margin-bottom: 22px;
}

section {
  margin-top: 26px;
}

section h2 {
  font-size: 1.3rem;
  margin-bottom: 10px;
  border-bottom: 2px solid #e8ecfa;
  padding-bottom: 6px;
  color: #151b49;
}

section h3 {
  font-size: 1.07rem;
  margin: 16px 0 8px;
  color: #1f2b7b;
}

ul {
  margin: 10px 0 14px 24px;
}

li {
  margin-bottom: 7px;
}

.eq {
  margin: 15px 0;
  padding: 12px;
  border: 1px solid #e4e8f8;
  border-left: 3px solid #6a7fe8;
  border-radius: 8px;
  background: var(--note);
  text-align: center;
  overflow-x: auto;
}

/* Prevent MathJax display-mode SVGs from overflowing narrow viewports
   (they are not always wrapped in .eq, e.g. inside <li> or <p>). */
mjx-container[display="true"] {
  display: block !important;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

pre.code {
  margin: 15px 0;
  padding: 12px 14px;
  border: 1px solid #e4e8f8;
  border-left: 3px solid #6a7fe8;
  border-radius: 8px;
  background: #f4f6ff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  overflow-x: auto;
  text-align: left;
}

.table-wrap {
  overflow-x: auto;
  margin: 14px 0 8px;
  border: 1px solid #e5e9fa;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.92rem;
}

th,
td {
  border-bottom: 1px solid #edf0fb;
  padding: 10px 12px;
  vertical-align: top;
  text-align: left;
}

th {
  color: #161d4a;
  background: #f6f8ff;
  font-weight: 700;
}

.badge-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.badge {
  border: 1px solid #dee5ff;
  background: #f7f9ff;
  border-radius: 10px;
  padding: 10px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.86rem;
  color: #384382;
}

.section-lead {
  color: var(--muted);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.95rem;
  text-align: left;
}

.pipeline {
  display: flex;
  align-items: stretch;
  gap: 7px;
  margin: 16px 0 10px;
  overflow-x: auto;
  padding: 3px 2px 8px;
}

.pipeline-node {
  flex: 1 0 112px;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 11px;
  border: 1px solid #dfe4f4;
  border-radius: 9px;
  background: #fafbff;
  font-family: 'IBM Plex Sans', sans-serif;
}

.pipeline-node--focus {
  border-color: #b9c5ff;
  background: #f0f3ff;
}

.pipeline-node--output {
  border-color: #b9d9d2;
  background: #f1faf7;
}

.pipeline-index {
  color: var(--accent);
  font: 700 0.7rem/1 'JetBrains Mono', monospace;
  letter-spacing: 0.06em;
}

.pipeline-node strong {
  color: #171d49;
  font-size: 0.86rem;
}

.pipeline-node small {
  color: #68708e;
  font-size: 0.73rem;
  line-height: 1.35;
}

.pipeline-arrow {
  align-self: center;
  color: #8892bd;
  font: 700 1.2rem/1 'IBM Plex Sans', sans-serif;
}

.pipeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  color: #68708e;
  font: 0.78rem 'IBM Plex Sans', sans-serif;
}

.pipeline-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: #b9c5ff;
}

.legend-swatch--external { background: #d9b36a; }
.legend-swatch--ternary { background: #9bcfc3; }

.ternary-explorer {
  margin-top: 22px;
  padding: 17px;
  border: 1px solid #d8e0ff;
  border-radius: 10px;
  background: linear-gradient(145deg, #fbfcff, #f2f5ff);
  font-family: 'IBM Plex Sans', sans-serif;
}

.explorer-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 15px;
}

.explorer-heading h3 {
  margin: 0 0 4px;
  color: #171d49;
}

.explorer-heading p,
.explorer-note {
  margin: 0;
  color: #68708e;
  font-size: 0.84rem;
  text-align: left;
}

.explorer-readout {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid #cdd7ff;
  border-radius: 7px;
  color: #27367c;
  background: #fff;
  font: 0.82rem 'JetBrains Mono', monospace;
}

.explorer-grid {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 175px minmax(0, 1fr);
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 16px;
}

.explorer-grid label {
  color: #3f486e;
  font-size: 0.84rem;
}

.explorer-grid output {
  display: inline-block;
  min-width: 38px;
  color: #1f2b7b;
  font: 0.78rem 'JetBrains Mono', monospace;
}

.explorer-grid input { width: 100%; accent-color: var(--accent); }

.ternary-state-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  max-width: 280px;
  margin: 0 auto 11px;
}

.ternary-cell {
  display: grid;
  place-items: center;
  min-height: 40px;
  border: 1px solid #dbe1f1;
  border-radius: 5px;
  background: #fff;
  color: #6a718c;
  font: 0.7rem 'JetBrains Mono', monospace;
  transition: 0.15s ease;
}

.ternary-cell.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(46, 77, 224, 0.2);
}

.references {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.93rem;
  line-height: 1.62;
}

.references li {
  margin-bottom: 9px;
}

.footer-bar {
  margin-top: 28px;
  border-top: 1px solid #e8ecfa;
  padding-top: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.88rem;
  color: #62698b;
}

.footer-bar a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
  }

  .badge-row {
    grid-template-columns: 1fr;
  }

  .pipeline {
    align-items: center;
  }

  .explorer-grid {
    grid-template-columns: 145px minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .explorer-heading {
    flex-direction: column;
  }

  .explorer-readout {
    width: 100%;
  }

  .explorer-grid {
    grid-template-columns: 1fr;
  }

  .explorer-grid input {
    margin-bottom: 5px;
  }

  .calc-form {
    grid-template-columns: 1fr !important;
  }

  .calc-results {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .faq-list dt {
    font-size: 0.92rem;
  }
}

/* Back-to-top */
.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  transition: 0.25s ease;
  pointer-events: none;
  z-index: 1000;
}

.back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Active TOC link */
.toc a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

/* Claims table status badges */
.badge-status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font: 700 0.72rem 'IBM Plex Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-status--established { background: #d1fae5; color: #065f46; }
.badge-status--projection { background: #dbeafe; color: #1e40af; }
.badge-status--hypothesis { background: #fef3c7; color: #92400e; }
.badge-status--planned { background: #f3e8ff; color: #6b21a8; }

/* Deployment diagram */
.deploy-diagram {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid #e5e9fa;
  border-radius: 10px;
  background: #fbfcff;
  overflow-x: auto;
}

.deploy-diagram svg {
  min-width: 760px;
  display: block;
  margin: 0 auto;
}

/* Memory calculator */
.calc-form {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 60px;
  align-items: center;
  gap: 10px 14px;
  margin: 16px 0;
  padding: 16px;
  border: 1px solid #dfe4f4;
  border-radius: 10px;
  background: #f7f9ff;
  font-family: 'IBM Plex Sans', sans-serif;
}

.calc-form label {
  color: #3f486e;
  font-size: 0.86rem;
}

.calc-form input[type="number"],
.calc-form input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  padding: 5px 8px;
  border: 1px solid #d0d7f0;
  border-radius: 6px;
  font: 0.85rem 'JetBrains Mono', monospace;
}

.calc-form input[type="range"] {
  padding: 0;
}

.calc-form output {
  color: #1f2b7b;
  font: 0.85rem 'JetBrains Mono', monospace;
  text-align: right;
}

.calc-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.calc-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border: 1px solid #dfe4f4;
  border-radius: 10px;
  background: #fff;
  text-align: center;
}

.calc-card strong {
  color: var(--primary);
  font: 700 1.15rem 'JetBrains Mono', monospace;
}

.calc-card span {
  color: #68708e;
  font: 0.78rem 'IBM Plex Sans', sans-serif;
}

/* FAQ */
.faq-list {
  margin: 12px 0 0;
}

.faq-list dt {
  margin: 18px 0 6px;
  color: #151b49;
  font: 700 1rem 'IBM Plex Sans', sans-serif;
  cursor: pointer;
}

.faq-list dd {
  margin: 0 0 10px 0;
  padding: 12px 14px;
  border-left: 3px solid #6a7fe8;
  background: #f7f9ff;
  border-radius: 0 8px 8px 0;
  color: #3c4268;
  font-size: 0.96rem;
}

/* BibTeX buttons */
.bibtex-btn {
  margin-left: 6px;
  padding: 2px 8px;
  border: 1px solid #c7d0f0;
  border-radius: 12px;
  background: #f0f3ff;
  color: var(--accent);
  font: 600 0.72rem 'IBM Plex Sans', sans-serif;
  cursor: pointer;
  transition: 0.15s ease;
}

.bibtex-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Emulator styles */
.model-emulator {
  margin-top: 26px;
}

.emulator-panel {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid #dfe4f4;
  border-radius: 10px;
  background: #fbfcff;
}

.emulator-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-btn {
  all: initial;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #dbe1f1;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: 0.2s ease;
  width: 100%;
}

.step-btn:hover {
  background: var(--accent-soft);
  border-color: #b9c5ff;
}

.step-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(46, 77, 224, 0.15);
}

.step-num {
  font: 700 1rem 'JetBrains Mono', monospace;
  opacity: 0.8;
}

.step-btn.is-active .step-num {
  opacity: 1;
}

.step-btn div {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.35;
}

.step-btn strong {
  font-size: 0.84rem;
  font-weight: 700;
}

.step-btn small {
  font-size: 0.72rem;
  opacity: 0.7;
}

.emulator-display {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.emulator-terminal {
  border: 1px solid #1a1b22;
  border-radius: 8px;
  background: #0b0b12;
  overflow: hidden;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #171721;
  border-bottom: 1px solid #232332;
}

.terminal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.terminal-dot.red { background: #ef4444; }
.terminal-dot.yellow { background: #eab308; }
.terminal-dot.green { background: #22c55e; }

.terminal-title {
  margin-left: 6px;
  color: #a6abc4;
  font: 500 0.7rem 'JetBrains Mono', monospace;
}

.terminal-body {
  margin: 0;
  padding: 14px;
  border: none;
  background: transparent;
  color: #22c55e;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.80rem;
  line-height: 1.5;
  white-space: pre-wrap;
  height: 155px;
  overflow-y: auto;
}

.emulator-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border: 1px solid #dfe4f4;
  border-radius: 8px;
  background: #fff;
  text-align: center;
  font-family: 'IBM Plex Sans', sans-serif;
}

.metric-label {
  font-size: 0.7rem;
  color: #6a718c;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.metric-val {
  color: var(--primary);
  font: 700 0.95rem 'JetBrains Mono', monospace;
}

.emulator-visualizer {
  display: grid;
  place-items: center;
  min-height: 110px;
  border: 1px solid #dfe4f4;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.mini-svg {
  width: 100px;
  height: 100px;
}

.gate-bar {
  width: 100%;
  max-width: 320px;
  height: 16px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f1f5f9;
  overflow: hidden;
  margin-bottom: 6px;
}

.gate-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.gate-label {
  color: #475569;
  font: 0.78rem 'JetBrains Mono', monospace;
}

@media (max-width: 820px) {
  .emulator-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .emulator-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media print {
  .model-emulator,
  .step-btn,
  .emulator-panel {
    display: none !important;
  }
}

/* CRATER Tiny chat demo */
.crater-chat {
  margin-top: 28px;
}

.chat-heading,
.chat-footer,
.chat-telemetry {
  display: flex;
  align-items: center;
}

.chat-heading {
  justify-content: space-between;
  gap: 16px;
}

.chat-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid #a7d7ce;
  border-radius: 999px;
  background: #f1faf7;
  color: #0f615a;
  font: 700 0.7rem 'IBM Plex Sans', sans-serif;
  text-transform: uppercase;
}

.chat-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

.chat-disclaimer {
  margin: 12px 0;
  padding: 9px 12px;
  border-left: 3px solid #caa14b;
  background: #fffaf0;
  color: #5c4a24;
  font: 0.78rem/1.5 'IBM Plex Sans', sans-serif;
}

.chat-shell {
  overflow: hidden;
  border: 1px solid #ccd5ed;
  border-radius: 8px;
  background: #f8faff;
  box-shadow: 0 12px 30px rgba(31, 43, 123, 0.08);
}

.model-file-inspector {
  margin: 0;
  padding: 16px 18px 14px;
  border-bottom: 1px solid #ccd5ed;
  background: #fff;
  font-family: 'IBM Plex Sans', sans-serif;
}

.model-file-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.model-file-heading h3 {
  margin: 2px 0 0;
  color: #171d49;
  font: 700 1rem 'JetBrains Mono', monospace;
  letter-spacing: 0;
}

.model-file-status {
  padding: 4px 7px;
  border: 1px solid #d7b768;
  border-radius: 4px;
  background: #fff9e8;
  color: #725714;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
}

.model-file-warning,
.model-file-footnote {
  text-align: left;
}

.model-file-warning {
  margin: 9px 0;
  color: #555e78;
  font-size: 0.76rem;
  line-height: 1.45;
}

.model-load-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 12px;
  color: #34416b;
  font: 600 0.68rem 'JetBrains Mono', monospace;
}

.model-load-flow span {
  padding: 4px 6px;
  border-bottom: 2px solid #8ea0e7;
  background: #f1f4ff;
}

.model-load-flow i {
  color: #7a849e;
  font-style: normal;
}

.model-composition {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid #dce2f1;
  border-bottom: 1px solid #dce2f1;
}

.model-composition > div {
  min-width: 0;
  padding: 10px;
  border-right: 1px solid #dce2f1;
  transition: background 0.16s ease, box-shadow 0.16s ease;
}

.model-composition > div:last-child {
  border-right: 0;
}

.model-composition > div.is-active {
  background: #fff6d9;
  box-shadow: inset 0 3px 0 #c18b18;
}

.model-composition > div.is-used:not(.is-active) {
  background: #f1faf7;
  box-shadow: inset 0 3px 0 #289184;
}

.model-composition dt,
.model-composition dd,
.model-composition span {
  overflow-wrap: anywhere;
}

.model-composition dt {
  color: #182256;
  font-size: 0.72rem;
  font-weight: 700;
}

.model-composition dd {
  margin: 4px 0 7px;
  color: #505a76;
  font-size: 0.66rem;
  line-height: 1.38;
}

.model-composition span {
  color: #167268;
  font: 600 0.58rem 'JetBrains Mono', monospace;
}

.model-file-footnote {
  margin: 9px 0 0;
  color: #68718a;
  font-size: 0.66rem;
  line-height: 1.4;
}

.chat-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
  min-height: 390px;
}

.chat-transcript {
  height: 390px;
  overflow-y: auto;
  padding: 22px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.88)),
    repeating-linear-gradient(0deg, transparent 0 31px, #dfe5f5 32px);
  scrollbar-color: #b9c5e7 transparent;
}

.chat-process {
  min-width: 0;
  padding: 16px;
  border-left: 1px solid #d9e0f1;
  background: #111522;
  color: #eef2ff;
  font-family: 'IBM Plex Sans', sans-serif;
}

.process-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}

.process-eyebrow {
  display: block;
  color: #8fa2e8;
  font-size: 0.61rem;
  font-weight: 700;
  text-transform: uppercase;
}

.process-heading h3 {
  margin: 1px 0 0;
  color: #fff;
  font-size: 0.92rem;
  letter-spacing: 0;
}

.process-clock {
  padding: 3px 6px;
  border: 1px solid #343b55;
  border-radius: 4px;
  color: #9da8c7;
  font: 0.6rem 'JetBrains Mono', monospace;
  text-transform: uppercase;
}

.process-steps {
  list-style: none;
  display: grid;
  gap: 5px;
}

.process-steps li {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 9px;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 7px;
  border: 1px solid #252b3e;
  border-radius: 5px;
  background: #181d2c;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.process-steps li.is-active {
  transform: translateX(3px);
  border-color: #6f86ef;
  background: #202b58;
}

.process-steps li.is-complete {
  border-color: #286c66;
  background: #152925;
}

.process-steps li.is-skipped {
  opacity: 0.62;
  border-style: dashed;
}

.process-index {
  color: #687492;
  font: 0.66rem 'JetBrains Mono', monospace;
}

.process-steps strong,
.process-steps small {
  display: block;
}

.process-steps strong {
  color: #e9edff;
  font-size: 0.7rem;
  line-height: 1.2;
}

.process-steps small {
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: #8e98b5;
  font-size: 0.59rem;
  line-height: 1.25;
}

.process-state {
  width: 7px;
  height: 7px;
  border: 1px solid #69738e;
  border-radius: 50%;
}

.is-active .process-state {
  border-color: #9fb0ff;
  background: #7890ff;
  box-shadow: 0 0 0 3px rgba(120, 144, 255, 0.16);
}

.is-complete .process-state {
  border-color: #62c9bc;
  background: #62c9bc;
}

.is-skipped .process-state {
  border-radius: 1px;
  border-color: #737d97;
  background: transparent;
}

.process-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 11px;
  color: #7f89a5;
  font-size: 0.58rem;
  text-transform: uppercase;
}

.process-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.process-legend i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.legend-active { background: #7890ff; }
.legend-complete { background: #62c9bc; }
.legend-skipped { border: 1px solid #737d97; border-radius: 1px !important; }

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 82%;
  margin-bottom: 18px;
  font-family: 'IBM Plex Sans', sans-serif;
}

.chat-message--user {
  flex-direction: row-reverse;
  margin-left: auto;
}

.chat-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font: 700 0.72rem 'JetBrains Mono', monospace;
}

.chat-message--user .chat-avatar {
  background: #0f766e;
}

.chat-bubble {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #dbe1f1;
  border-radius: 4px 8px 8px 8px;
  background: #fff;
}

.chat-message--user .chat-bubble {
  border-color: #b9c5ff;
  border-radius: 8px 4px 8px 8px;
  background: var(--accent-soft);
}

.chat-author {
  display: block;
  margin-bottom: 3px;
  color: var(--primary);
  font-size: 0.73rem;
  font-weight: 700;
}

.chat-author small {
  color: var(--muted);
  font-weight: 500;
}

.chat-bubble p {
  overflow-wrap: anywhere;
  color: #31374f;
  font-size: 0.88rem;
  line-height: 1.55;
}

.chat-message.is-typing .chat-bubble p {
  color: var(--muted);
  font-style: italic;
}

.chat-suggestions {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 14px 0;
}

.chat-suggestions button,
.chat-clear {
  border: 1px solid #cbd4eb;
  background: #fff;
  color: #35406b;
  cursor: pointer;
  font: 600 0.74rem 'IBM Plex Sans', sans-serif;
}

.chat-suggestions button {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
}

.chat-suggestions button:hover,
.chat-clear:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
  margin: 10px 14px;
  padding: 7px;
  border: 1px solid #bec9e6;
  border-radius: 8px;
  background: #fff;
}

.chat-composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 77, 224, 0.1);
}

.chat-composer textarea {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  border: 0;
  outline: 0;
  padding: 6px;
  background: transparent;
  color: var(--ink);
  font: 0.88rem/1.45 'IBM Plex Sans', sans-serif;
}

.chat-send {
  align-self: end;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: 700 1.2rem 'IBM Plex Sans', sans-serif;
}

.chat-send:hover { background: var(--primary); }
.chat-send:disabled { cursor: wait; opacity: 0.55; }

.chat-footer {
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-top: 1px solid #dfe4f4;
  background: #f1f4fb;
  font-family: 'IBM Plex Sans', sans-serif;
}

.chat-telemetry {
  flex-wrap: wrap;
  gap: 12px;
  color: #66708e;
  font-size: 0.68rem;
  text-transform: uppercase;
}

.chat-telemetry strong {
  color: var(--primary);
  font-family: 'JetBrains Mono', monospace;
}

.chat-clear {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 5px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .chat-heading,
  .chat-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-workspace {
    grid-template-columns: 1fr;
  }

  .model-file-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .model-composition {
    grid-template-columns: 1fr;
  }

  .model-composition > div {
    border-right: 0;
    border-bottom: 1px solid #dce2f1;
  }

  .model-composition > div:last-child {
    border-bottom: 0;
  }

  .chat-transcript {
    height: 350px;
    padding: 15px 12px;
  }

  .chat-process {
    border-top: 1px solid #d9e0f1;
    border-left: 0;
  }

  .chat-message {
    max-width: 94%;
  }

  .chat-clear {
    align-self: stretch;
  }
}

@media print {
  .crater-chat {
    display: none !important;
  }
}

/* Angular attention visualizer */
.angular-panel {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  margin: 16px 0;
  padding: 16px;
  border: 1px solid #dfe4f4;
  border-radius: 10px;
  background: #fbfcff;
}

.angular-circle {
  width: 100%;
  max-width: 260px;
  height: auto;
  margin: 0 auto;
}

.angular-controls {
  font-family: 'IBM Plex Sans', sans-serif;
}

.angular-controls label {
  display: block;
  margin-bottom: 4px;
  color: #3f486e;
  font-size: 0.84rem;
}

.angular-controls output {
  color: #1f2b7b;
  font: 0.78rem 'JetBrains Mono', monospace;
}

.angular-controls input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin-bottom: 12px;
}

.angular-readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 6px 0 10px;
}

/* Comparison table */
.comparison-table td:nth-child(2) { color: #7a3d1f; }
.comparison-table td:nth-child(3) { color: #145049; font-weight: 600; }

/* Glossary */
.glossary-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin: 12px 0 0;
}

.glossary-list > div {
  padding: 12px 14px;
  border: 1px solid #dfe4f4;
  border-radius: 10px;
  background: #f7f9ff;
}

.glossary-list dt {
  color: var(--primary);
  font: 700 0.95rem 'JetBrains Mono', monospace;
  margin-bottom: 4px;
}

.glossary-list dd {
  margin: 0;
  color: #3c4268;
  font: 0.86rem 'IBM Plex Sans', sans-serif;
}

/* Copy code buttons */
pre.code { position: relative; }

.copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 9px;
  border: 1px solid #c7d0f0;
  border-radius: 12px;
  background: #eef2ff;
  color: var(--accent);
  font: 600 0.72rem 'IBM Plex Sans', sans-serif;
  cursor: pointer;
  transition: 0.15s ease;
}

.copy-code-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* Citation box */
.cite-tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0 10px;
}

.cite-tab {
  padding: 6px 14px;
  border: 1px solid #d0d7f0;
  border-radius: 8px;
  background: #f7f9ff;
  color: #3f486e;
  font: 600 0.82rem 'IBM Plex Sans', sans-serif;
  cursor: pointer;
  transition: 0.15s ease;
}

.cite-tab.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.cite-content { margin-top: 0; }

.copy-cite-btn {
  margin-top: 4px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: 600 0.85rem 'IBM Plex Sans', sans-serif;
  cursor: pointer;
}

.copy-cite-btn:hover { filter: brightness(1.08); }

@media (max-width: 680px) {
  mjx-container:not([display="true"]) {
    display: inline-block !important;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    vertical-align: middle;
  }

  .angular-panel {
    grid-template-columns: 1fr;
  }

  .angular-readout {
    grid-template-columns: 1fr;
  }
}

/* Print styles */
@media print {
  .lp-top,
  .toc,
  .back-to-top,
  .copy-code-btn,
  .copy-cite-btn,
  .bibtex-btn,
  .cite-tabs,
  .ternary-explorer,
  .angular-controls input,
  .calc-form input[type="range"],
  #memory-calculator .calc-form,
  .footer-bar {
    display: none !important;
  }

  html, body {
    background: #fff !important;
    color: #000 !important;
  }

  .shell {
    display: block;
    width: 100%;
    margin: 0;
  }

  .paper {
    box-shadow: none;
    border: none;
    padding: 0;
  }

  section,
  .table-wrap,
  .eq,
  pre.code,
  .calc-card,
  .faq-list dd {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  a { color: #000 !important; text-decoration: underline; }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
    color: #444;
  }
}
