:root {
  --bg: #f2f5fb;
  --surface: #ffffff;
  --ink: #10142b;
  --muted: #4c5573;
  --line: #10142b;
  --code-bg: #e7edf8;
  --navy: #1a1fb4;
  --sky: #a9d2ff;
  --teal: #0e8a78;
  --rose: #c0365a;
  --link: #2131c4;
  --on-accent: #10142b;
  --on-dark-accent: #ffffff;
  --shadow: 4px 4px 0 var(--line);
  /* categorical colours for spectral zones (graph, legends, class bars) */
  --z1: #2f4ae0;
  --z2: #e08a12;
  --z3: #0e8a78;
  --z4: #c0365a;
  --z5: #7a4cc2;
  --z6: #5f8a1e;
  --z7: #d2552b;
  --z8: #3f7fb0;
  --g-bg: #f8faff;
  --g-edge-lo: #c9d2e8;
  --g-edge-hi: #2f3656;
  --g-node-border: #10142b;
  --g-plain-fill: #ffffff;
  --g-bg-fill: #e3e8f3;
  --g-class-fill: #10142b;
  --g-class-text: #ffffff;
  --g-accent: #c0365a;
  --radius: 10px;
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

/* dark theme: only when picked with the nav toggle (assets/landing.js); light is the default */
:root[data-theme="dark"] {
  --bg: #0d1120;
  --surface: #161b2f;
  --ink: #e7ebfa;
  --muted: #9ba4c4;
  --line: #3d4769;
  --code-bg: #1d2440;
  --navy: #7d8bff;
  --sky: #8ec2ff;
  --teal: #3cc0aa;
  --rose: #ee6f90;
  --link: #a3b6ff;
  --on-dark-accent: #0d1120;
  --shadow: 4px 4px 0 #000;
  --z1: #6f86ff;
  --z2: #f0a640;
  --z3: #3cc0aa;
  --z4: #ee6f90;
  --z5: #a888e6;
  --z6: #94be4f;
  --z7: #f08159;
  --z8: #6fb0de;
  --g-bg: #12172a;
  --g-edge-lo: #333c5c;
  --g-edge-hi: #c9d2ee;
  --g-node-border: #05070f;
  --g-plain-fill: #2a3150;
  --g-bg-fill: #222842;
  --g-class-fill: #e7ebfa;
  --g-class-text: #10142b;
  --g-accent: #ee6f90;
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 76px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

img { max-width: 100%; height: auto; display: block; }

code, pre { font-variant-ligatures: none; }
code { font-family: var(--mono); font-size: .86em; }
:not(pre) > code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; overflow-wrap: anywhere; }

h2 { font-size: clamp(1.6rem, 3.2vw, 2.1rem); line-height: 1.2; margin: 0 0 1.25rem; letter-spacing: -.01em; }
h3 { font-size: 1.1rem; margin: 0 0 .5rem; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* nav */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--line);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.nav-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.nav-mark { width: 44px; height: 28px; overflow: visible; }
.nav-mark path { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.nav-mark .w1 { stroke: var(--sky); }
.nav-mark .w2 { stroke: var(--navy); }
.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a:not(.btn) { color: var(--ink); text-decoration: none; font-weight: 500; }
.nav-links a:not(.btn):hover { color: var(--link); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .7em 1.3em; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-weight: 700; text-decoration: none;
  box-shadow: var(--shadow); transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--line); text-decoration: none; }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--line); }
.btn-primary { background: var(--navy); color: var(--on-dark-accent); }
.btn-sm { padding: .35em .9em; font-size: .92rem; box-shadow: 3px 3px 0 var(--line); }
.theme-toggle {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; cursor: pointer;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  box-shadow: 3px 3px 0 var(--line); transition: transform .08s, box-shadow .08s;
}
.theme-toggle:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--line); }
.theme-toggle:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .sun, :root[data-theme="dark"] .theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }

/* hero */
.hero { text-align: center; padding: 56px 0 40px; }
.hero-logo { width: min(520px, 90%); margin: 0 auto 22px; }
/* the logo is drawn in black ink; give it a paper backing on dark backgrounds */
:root[data-theme="dark"] .hero-logo { background: #f2f5fb; border-radius: 14px; padding: 12px 16px; }
.lede { font-size: clamp(1.1rem, 2.2vw, 1.35rem); max-width: 760px; margin: 0 auto 22px; color: var(--muted); }
.lede strong { color: var(--ink); }

.tags { list-style: none; padding: 0; margin: 0 0 30px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.tag {
  border: 2px solid var(--line); border-radius: 6px; padding: .2em .8em;
  font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em;
  background: var(--surface);
}
.tag-sky { background: var(--sky); color: var(--on-accent); }
.tag-navy { background: var(--navy); color: var(--on-dark-accent); }
.tag-teal { background: var(--teal); color: var(--on-dark-accent); }

.install {
  display: inline-flex; align-items: center; gap: 14px; max-width: 100%;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 8px 8px 8px 18px; box-shadow: var(--shadow);
}
.install code { font-size: 1.05rem; white-space: nowrap; overflow-x: auto; background: none; padding: 0; min-width: 0; }
.install .prompt { color: var(--muted); user-select: none; }
.install-block { display: flex; justify-content: space-between; margin: 6px 0 12px; box-shadow: 3px 3px 0 var(--line); }
.install-block code { font-size: .92rem; }
.meta { color: var(--muted); font-size: .95rem; margin: 16px 0 26px; }
.cta { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

.copy {
  font: 600 .82rem var(--font); cursor: pointer; flex-shrink: 0;
  border: 2px solid var(--line); border-radius: 6px; padding: .35em .8em;
  background: var(--sky); color: var(--on-accent);
}
.copy:hover { filter: brightness(1.06); }
.copy.done { background: var(--teal); color: var(--on-dark-accent); }

/* cards */
.card {
  background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

.figure-section { padding-bottom: 16px; }
.fig { margin: 0; overflow: hidden; }
/* the figures are Plotly exports on white; keep them on white in both themes */
.fig .plot { display: block; background: #fff; overflow-x: auto; border-bottom: 2px solid var(--line); }
.fig .plot iframe { display: block; width: 100%; height: 480px; border: 0; }
.fig figcaption { padding: 14px 18px; color: var(--muted); font-size: .95rem; }
.fig figcaption strong { color: var(--ink); }

/* interactive predicate graph (assets/graph.js) */
.smx-graph { min-height: 120px; }
.smx-graph.live { background: var(--g-bg); }
.graph-fallback { padding: 18px; color: var(--muted); margin: 0; }
.g-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-bottom: 2px solid var(--line); background: var(--surface);
}
.seg, .g-zoom { display: flex; }
.g-toolbar .seg + .seg { margin-right: auto; }
.seg button, .g-zoom button {
  font: 600 .85rem var(--font); color: var(--ink); background: var(--surface); cursor: pointer;
  border: 2px solid var(--line); padding: .3em .8em; margin-left: -2px; min-width: 2.2em;
}
.seg button:first-child, .g-zoom button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg button:last-child, .g-zoom button:last-child { border-radius: 0 6px 6px 0; }
.seg button[aria-pressed="true"] { background: var(--sky); color: var(--on-accent); }
.seg button:hover, .g-zoom button:hover { background: var(--code-bg); }
.seg button[aria-pressed="true"]:hover { background: var(--sky); }
.g-stage { position: relative; }
.g-cy { height: 560px; outline: 2px solid transparent; outline-offset: -4px; transition: outline-color .15s; }
.smx-graph.active .g-cy { outline-color: color-mix(in srgb, var(--navy) 55%, transparent); }
.g-hint {
  position: absolute; left: 12px; bottom: 10px; max-width: calc(100% - 24px); pointer-events: none;
  font-size: .8rem; color: var(--muted); background: color-mix(in srgb, var(--g-bg) 88%, transparent);
  padding: 2px 8px; border-radius: 6px; transition: color .15s, background .15s;
}
.smx-graph.nudge .g-hint { color: var(--on-accent); background: var(--sky); font-weight: 600; }
.g-cover {
  position: absolute; inset: 0; width: 100%; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--g-bg) 35%, transparent);
  font: 700 1rem var(--font); color: var(--ink);
}
.g-cover span {
  display: inline-block; padding: .5em 1.1em; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--sky); color: var(--on-accent); box-shadow: 3px 3px 0 var(--line);
}
.g-done {
  position: absolute; right: 10px; top: 10px; z-index: 3;
  font: 700 .85rem var(--font); border: 2px solid var(--line); border-radius: 6px;
  background: var(--sky); color: var(--on-accent); padding: .35em .9em;
}
.g-side {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: 300px; overflow-y: auto; z-index: 2;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; font-size: .9rem;
}
.g-side h4 { font: 600 .95rem/1.35 var(--mono); margin: 0 26px 4px 0; overflow-wrap: anywhere; font-variant-ligatures: none; }
.g-side h5 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 0 6px; }
.g-sub { margin: 0; color: var(--muted); }
.g-close {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; cursor: pointer;
  border: 2px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 1.1rem; line-height: 1;
}
.g-side ul { list-style: none; margin: 0; padding: 0; }
.g-side li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.g-side li button {
  all: unset; cursor: pointer; color: var(--link); font: .82rem var(--mono); font-variant-ligatures: none;
  text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere;
}
.g-side li span { color: var(--muted); font-variant-numeric: tabular-nums; }
.g-side dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin: 0; }
.g-side dt { color: var(--muted); }
.g-side dd { margin: 0; font-variant-numeric: tabular-nums; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid var(--line); vertical-align: -1px; }
.g-legend {
  display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 14px; font-size: .85rem;
  border-top: 2px solid var(--line); background: var(--surface);
}
.g-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.g-legend .muted { color: var(--muted); }
.ramp { display: inline-block; width: 90px; height: 10px; border: 1.5px solid var(--line); border-radius: 3px; margin: 0 4px; }
.fig .smx-graph { border-bottom: 2px solid var(--line); }

.section { padding: 56px 16px 8px; }
.note { color: var(--muted); max-width: 780px; }
.small { font-size: .92rem; color: var(--muted); margin: 0; }

/* pipeline */
.pipeline { list-style: none; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.pipeline li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 0 4px; }
.pipeline li:not(:last-child)::after {
  content: "→"; position: absolute; right: -14px; top: 22px;
  color: var(--navy); font-weight: 700; font-size: 1.3rem;
}
.pipeline strong { font-size: 1rem; line-height: 1.25; margin-top: 8px; }
.pipeline li > span:last-child { color: var(--muted); font-size: .85rem; }
.step {
  width: 68px; height: 68px; border-radius: 50%; border: 2.5px solid var(--line);
  display: grid; place-items: center; box-shadow: 3px 3px 0 var(--line);
}
.step svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.step-pale { background: #e3ecfb; color: #10142b; }
.step-sky { background: var(--sky); color: #10142b; }
.step-blue { background: #5f8dff; color: #10142b; }
.step-navy { background: #1a1fb4; color: #ffffff; }
.step-teal { background: #0e8a78; color: #ffffff; }
.step-rose { background: #c0365a; color: #ffffff; }

/* output cards */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 18px; }
.metric { padding: 18px; border-top-width: 10px; }
.metric p { margin: 0; color: var(--muted); font-size: .95rem; }
.metric-sky { border-top-color: var(--sky); }
.metric-navy { border-top-color: var(--navy); }
.metric-teal { border-top-color: var(--teal); }
.metric-rose { border-top-color: var(--rose); }
.gallery { display: grid; gap: 18px; margin-bottom: 18px; }
.gallery .plot iframe { height: 440px; }

/* get started */
.steps { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.step-card { padding: 18px 20px; min-width: 0; }
.num {
  display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; margin-right: .3em;
  border: 2px solid var(--line); border-radius: 50%; background: var(--sky); color: var(--on-accent);
  font-size: .85rem; vertical-align: 1px;
}

.code-card { padding: 0; overflow: hidden; margin-bottom: 18px; }
.code-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px 12px 20px; border-bottom: 2px solid var(--line); }
.code-head h3 { margin: 0; }
pre {
  margin: 0; padding: 18px 20px; overflow-x: auto; background: var(--code-bg);
  font: .86rem/1.65 var(--mono); tab-size: 4;
}
.code-foot { padding: 14px 20px; border-top: 2px solid var(--line); }
pre .k { color: var(--rose); font-weight: 600; }
pre .s { color: var(--teal); }
pre .n, pre .c { color: var(--link); }
pre .m { color: var(--muted); font-style: italic; }

.doc-links { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.doc-link { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; text-decoration: none; color: var(--ink); transition: transform .08s, box-shadow .08s; }
.doc-link:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--line); }
.doc-link strong::after { content: " →"; color: var(--navy); }
.doc-link span { color: var(--muted); font-size: .9rem; }

#cite .code-card { margin-top: 18px; }

/* footer */
.footer { margin-top: 72px; border-top: 2px solid var(--line); padding: 22px 0 30px; color: var(--muted); font-size: .92rem; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.footer nav { display: flex; gap: 18px; flex-wrap: wrap; }

:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }

@media (max-width: 900px) {
  .grid, .doc-links { grid-template-columns: 1fr 1fr; }
  .pipeline { grid-template-columns: 1fr; gap: 22px; }
  .pipeline li {
    display: grid; grid-template-columns: 68px 1fr; grid-template-rows: auto auto;
    column-gap: 16px; row-gap: 0; align-content: center; text-align: left; padding: 0;
  }
  .pipeline .step { grid-row: 1 / 3; }
  .pipeline li strong { margin: 0; align-self: end; }
  .pipeline li > span:last-child { align-self: start; }
  .pipeline li:not(:last-child)::after { content: "↓"; right: auto; left: 24px; top: auto; bottom: -27px; font-size: 1.1rem; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .hide-sm { display: none; }
  .nav-links { gap: 14px; }
  .hero { padding-top: 36px; }
  .steps, .grid, .doc-links { grid-template-columns: 1fr; }
  .install code { font-size: .95rem; }
  /* plots keep a readable width on phones; the frame scrolls sideways */
  .fig .plot iframe { width: 760px; height: 420px; }
  .g-cy { height: 340px; }
  .g-side { position: static; width: auto; max-height: none; border-width: 2px 0 0; border-radius: 0; box-shadow: none; }
  .section { padding-top: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .doc-link { transition: none; }
}
