:root {
  --paper: #E8EDEB;
  --paper-2: #DEE5E2;
  --ink: #14263B;
  --graphite: #4D5863;
  --rule: #C3CECA;
  --blue: #3D6FE0;
  --blue-soft: #BCD0F5;
  --for: #1E7A68;
  --against: #A23B45;
  --panel: #12233A;
  --panel-2: #1A2F4B;
  --panel-line: #2C4566;
  --panel-text: #DCE6F2;
  --panel-dim: #8DA2BC;
  --amber: #C98A1B;

  --f: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --s-1: 0.8125rem;
  --s0: 1rem;
  --s1: 1.1875rem;
  --s2: 1.5rem;
  --s3: 2.125rem;
  --s4: clamp(2.5rem, 5.2vw, 4.25rem);
  --gap: clamp(1.25rem, 3vw, 2.5rem);
  --max: 1200px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--f);
  font-size: var(--s0);
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  /* engineering chart paper */
  background-image:
    linear-gradient(var(--paper-2) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-2) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; top: 1rem; }

/* nav */
.nav {
  max-width: var(--max); margin: 0 auto; padding: 1.25rem var(--gap);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.wordmark { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; text-decoration: none; }
.nav nav { display: flex; gap: 1.5rem; align-items: center; }
.nav nav a { text-decoration: none; color: var(--graphite); font-weight: 500; font-size: .95rem; }
.nav nav a:hover { color: var(--ink); }
.nav .nav-cta { color: var(--ink); border-bottom: 2px solid var(--blue); padding-bottom: 1px; }
@media (max-width: 860px) { .nav nav a:not(.nav-cta) { display: none; } }

/* buttons */
.btn { display: inline-block; font: inherit; font-weight: 600; text-decoration: none; padding: .8rem 1.35rem; border-radius: 6px; border: 2px solid var(--ink); cursor: pointer; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--panel-2); border-color: var(--panel-2); }
.btn-quiet { background: transparent; color: var(--ink); }
.btn-quiet:hover { background: var(--paper-2); }

/* hero */
.hero { max-width: var(--max); margin: 0 auto; padding: clamp(1.5rem, 5vw, 4rem) var(--gap) 0; }
.hero-copy { display: grid; grid-template-columns: 1.35fr 1fr; gap: var(--gap); align-items: end; }
h1 { font-size: var(--s4); line-height: 1.02; letter-spacing: -0.035em; font-weight: 800; margin: 0; max-width: 13ch; }
.lede { font-size: var(--s1); line-height: 1.5; margin: 0 0 1.5rem; max-width: 40ch; color: var(--ink); }
.ctas { display: flex; gap: .75rem; flex-wrap: wrap; }
.status-note { color: var(--graphite); font-size: .9rem; margin: 1rem 0 0; }
@media (max-width: 860px) { .hero-copy { grid-template-columns: 1fr; } }

/* instrument */
.instrument {
  margin-top: clamp(2rem, 5vw, 3.5rem);
  background: var(--panel); color: var(--panel-text);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 30px 60px -30px rgba(20, 38, 59, .55);
}
.inst-head { display: flex; align-items: center; gap: .75rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--panel-line); font-size: .9rem; }
.inst-title { font-weight: 600; }
.inst-clock { color: var(--panel-dim); margin-left: auto; font-variant-numeric: tabular-nums; }
.feed time, .tally dd, .detail li span:last-child { font-variant-numeric: tabular-nums; }
.inst-toggle { font: inherit; font-size: .85rem; color: var(--panel-text); background: transparent; border: 1px solid var(--panel-line); border-radius: 5px; padding: .25rem .7rem; cursor: pointer; }
.inst-toggle:hover { border-color: var(--panel-dim); }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: #4BC49A; box-shadow: 0 0 0 0 rgba(75,196,154,.6); animation: pulse 2.2s infinite; }
.paused .pulse { animation: none; background: var(--panel-dim); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(75,196,154,.55);} 70% { box-shadow: 0 0 0 9px rgba(75,196,154,0);} 100% { box-shadow: 0 0 0 0 rgba(75,196,154,0);} }

.inst-body { display: grid; grid-template-columns: 220px 1fr 300px; min-height: 380px; }
.steps { list-style: none; margin: 0; padding: .75rem 0; border-right: 1px solid var(--panel-line); }
.steps button {
  all: unset; box-sizing: border-box; width: 100%; display: flex; gap: .8rem; align-items: flex-start;
  padding: .6rem 1.1rem; cursor: pointer; color: var(--panel-dim); position: relative;
}
.steps button:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.steps .n { width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1px solid var(--panel-line); display: grid; place-items: center; font-size: .8rem; flex: none; }
.steps strong { display: block; font-weight: 600; color: inherit; font-size: .95rem; }
.steps em { display: block; font-style: normal; font-size: .8rem; color: var(--panel-dim); }
.steps button.done { color: var(--panel-text); }
.steps button.done .n { background: var(--panel-line); border-color: var(--panel-line); }
.steps button.active { color: #fff; }
.steps button.active .n { background: var(--blue); border-color: var(--blue); color: #fff; }
.steps button.active::before { content: ""; position: absolute; left: 0; top: .5rem; bottom: .5rem; width: 3px; background: var(--blue); }

.graph-wrap { position: relative; display: grid; place-items: center; padding: .5rem; }
#run-graph { width: 100%; height: 100%; max-height: 380px; }

.detail { border-left: 1px solid var(--panel-line); padding: 1.1rem 1.25rem; font-size: .92rem; }
.detail h3 { margin: 0 0 .5rem; font-size: 1.05rem; color: #fff; }
.detail p { margin: 0 0 .75rem; color: var(--panel-text); }
.detail .d-sub { color: var(--panel-dim); font-size: .82rem; }
.detail ul { margin: 0; padding: 0; list-style: none; }
.detail li { padding: .35rem 0; border-top: 1px solid var(--panel-line); display: flex; justify-content: space-between; gap: .75rem; }
.detail li span:first-child { white-space: nowrap; }
.detail li span:last-child { color: var(--panel-dim); text-align: right; }
.detail .ok { color: #66D1A9 !important; }
.detail .no { color: #F08A94 !important; }
.detail .wait { color: #E5B556 !important; }
.detail .fade-in { animation: fadein .35s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

.inst-foot { margin: 0; padding: .7rem 1.25rem; border-top: 1px solid var(--panel-line); font-size: .8rem; color: var(--panel-dim); }

@media (max-width: 1000px) {
  .inst-body { grid-template-columns: 1fr; }
  .steps { display: grid; grid-template-columns: repeat(3, 1fr); border-right: 0; border-bottom: 1px solid var(--panel-line); }
  .steps em { display: none; }
  .detail { border-left: 0; border-top: 1px solid var(--panel-line); }
}
@media (max-width: 520px) { .steps { grid-template-columns: repeat(2, 1fr); } }

/* graph styles (shared) */
.g-edge { stroke: var(--panel-line); stroke-width: 1.2; fill: none; transition: stroke .5s, stroke-width .5s, opacity .5s; }
.g-edge.lit { stroke: var(--blue); stroke-width: 2; }
.g-edge.dim { opacity: .25; }
.g-node circle { fill: var(--panel-2); stroke: var(--panel-line); stroke-width: 1.5; transition: fill .5s, stroke .5s, r .5s; }
.g-node text { fill: var(--panel-dim); font: 500 11px var(--f); transition: fill .5s; }
.g-node.factor circle { fill: #2A2240; stroke: #6B5BA8; }
.g-node.lit circle { fill: var(--blue); stroke: #9DB8F5; }
.g-node.lit text { fill: #fff; }
.g-node.hot circle { fill: var(--amber); stroke: #F3CF85; }
.g-node.hot text { fill: #fff; }
.g-node.dim { opacity: .3; }
.packet { fill: #9DB8F5; }

/* sections */
section { scroll-margin-top: 1rem; }
.preview, .roadmap, .rigor, .join { max-width: var(--max); margin: 0 auto; padding: clamp(4rem, 9vw, 7rem) var(--gap) 0; }
.section-head { max-width: 46rem; margin-bottom: 2rem; }
h2 { font-size: var(--s3); line-height: 1.1; letter-spacing: -0.025em; margin: 0 0 .6rem; font-weight: 800; }
.section-head p { margin: 0; color: var(--graphite); font-size: var(--s1); }

/* console */
.console { background: #F6F8F7; border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--rule); overflow-x: auto; background: var(--paper); }
.tabs button { font: inherit; font-weight: 600; font-size: .95rem; color: var(--graphite); background: none; border: 0; padding: 1rem 1.25rem; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--blue); background: #F6F8F7; }
.tabs button:hover { color: var(--ink); }
.panel { padding: 1.5rem; }
.panel-note { margin: 1.25rem 0 0; font-size: .85rem; color: var(--graphite); }

.activity-grid { display: grid; grid-template-columns: 1fr 260px; gap: 1.5rem; }
.feed { list-style: none; margin: 0; padding: 0; height: 300px; overflow: hidden; position: relative; }
.feed li { display: grid; grid-template-columns: 4.2rem 1fr auto; gap: .75rem; align-items: baseline; padding: .6rem 0; border-bottom: 1px solid var(--rule); font-size: .93rem; }
.feed li.new { animation: fadein .45s ease both; }
.feed time { color: var(--graphite); font-size: .85rem; }
.feed .what { color: var(--ink); }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.tag-run { background: #DCE6FB; color: #2049A8; }
.tag-ok { background: #D4EDE6; color: #165C4E; }
.tag-no { background: #F4DCDF; color: #7E2630; }
.tag-wait { background: #F6E9CC; color: #7A5410; }
.tally { margin: 0; display: grid; gap: 1rem; align-content: start; }
.tally div { border-left: 3px solid var(--rule); padding-left: .9rem; }
.tally dt { font-size: .85rem; color: var(--graphite); }
.tally dd { margin: 0; font-size: var(--s3); font-weight: 700; letter-spacing: -0.02em; }
@media (max-width: 760px) { .activity-grid { grid-template-columns: 1fr; } .feed li { grid-template-columns: 1fr; gap: .2rem; } }

.graph-split { display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem; align-items: start; }
#world-graph { width: 100%; background: var(--panel); border-radius: 10px; }
.edge-info h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
.edge-info p { margin: 0 0 .6rem; color: var(--graphite); font-size: .92rem; }
.edge-info dl { margin: .5rem 0 0; font-size: .88rem; }
.edge-info dt { color: var(--graphite); }
.edge-info dd { margin: 0 0 .5rem; }
#world-graph .g-edge { cursor: pointer; stroke-width: 2; }
#world-graph .g-edge:hover, #world-graph .g-edge.sel { stroke: var(--blue); stroke-width: 3; }
#world-graph .hit { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
#world-graph .hit:focus-visible { outline: none; stroke: rgba(61,111,224,.35); }
@media (max-width: 860px) { .graph-split { grid-template-columns: 1fr; } }

table { border-collapse: collapse; width: 100%; }
.exp-table th, .exp-table td { text-align: left; padding: .8rem .75rem .8rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; font-size: .93rem; }
.exp-table th { font-size: .85rem; color: var(--graphite); font-weight: 600; }
.exp-table td:first-child { font-weight: 600; max-width: 30ch; }
@media (max-width: 760px) { .exp-table thead { display: none; } .exp-table tr { display: block; padding: .6rem 0; border-bottom: 1px solid var(--rule); } .exp-table td { display: block; border: 0; padding: .15rem 0; } }

.thesis-head h3 { font-size: var(--s2); line-height: 1.25; margin: .25rem 0 .5rem; letter-spacing: -0.015em; max-width: 34ch; }
.thesis-co { margin: 0; font-weight: 600; color: var(--graphite); }
.thesis-meta { margin: 0 0 1.25rem; color: var(--graphite); font-size: .9rem; }
.evidence { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.ev-col h4 { margin: 0 0 .5rem; font-size: 1rem; }
.ev-for h4 { color: var(--for); }
.ev-against h4 { color: var(--against); }
.ev-col ul { margin: 0; padding: 0; list-style: none; }
.ev-col li { padding: .65rem 0 .65rem .9rem; border-left: 3px solid; margin-bottom: .6rem; font-size: .93rem; }
.ev-for li { border-color: var(--for); }
.ev-against li { border-color: var(--against); }
.ev-col cite { display: block; font-style: normal; font-size: .8rem; color: var(--graphite); margin-top: .25rem; }
.thesis-status { margin-top: 1rem; display: flex; align-items: center; gap: .75rem; font-size: .93rem; }
.meter { width: 120px; height: 8px; border-radius: 4px; background: var(--against); overflow: hidden; display: inline-block; flex: none; }
.meter span { display: block; height: 100%; background: var(--for); }
@media (max-width: 760px) { .evidence { grid-template-columns: 1fr; } }

.fc-wrap { display: grid; grid-template-columns: 1fr 170px; gap: 1.25rem; align-items: center; }
#fan { width: 100%; }
.fc-legend p { margin: 0 0 .5rem; display: flex; align-items: center; gap: .5rem; font-size: .88rem; }
.key { display: inline-block; width: 22px; height: 10px; border-radius: 2px; }
.key-line { height: 3px; background: var(--ink); }
.key-50 { background: #8FAEEB; }
.key-80 { background: #D3DFF7; }
@media (max-width: 760px) { .fc-wrap { grid-template-columns: 1fr; } }

/* roadmap */
.road th, .road td { text-align: left; padding: 1rem 1rem 1rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.road thead th { font-size: .85rem; color: var(--graphite); font-weight: 600; padding-top: 0; }
.road tbody th { font-weight: 700; width: 26%; }
.road td:nth-child(2) { color: var(--graphite); max-width: 52ch; }
.st { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.st::before { content: ""; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.st-1::before { background: var(--for); }
.st-2::before { background: var(--blue); }
.st-3::before { background: transparent; border: 2px solid var(--blue); width: 6px; height: 6px; }
.st-4::before { background: transparent; border: 2px dashed var(--graphite); width: 6px; height: 6px; }
@media (max-width: 760px) { .road thead { display: none; } .road tr { display: block; padding: .8rem 0; border-bottom: 1px solid var(--rule); } .road th, .road td { display: block; border: 0; padding: .15rem 0; width: auto; } .st { white-space: normal; } }

/* rigor */
.rigor-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0; border-top: 2px solid var(--ink); }
.rigor-list div { padding: 1.25rem 1.25rem 1.25rem 0; border-bottom: 1px solid var(--rule); }
.rigor-list h3 { font-size: 1.05rem; margin: 0 0 .4rem; line-height: 1.3; }
.rigor-list p { margin: 0; color: var(--graphite); font-size: .93rem; }

/* join */
.join { display: grid; grid-template-columns: 1fr 1.15fr; gap: clamp(2rem, 5vw, 4rem); padding-bottom: clamp(4rem, 9vw, 7rem); }
.join-copy p { color: var(--graphite); font-size: var(--s1); max-width: 40ch; }
.join-copy a { font-weight: 600; }
.form { background: #F6F8F7; border: 1px solid var(--rule); border-radius: 12px; padding: 1.5rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; align-content: start; }
.field { display: grid; gap: .35rem; }
.field-wide { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .9rem; }
.form input, .form select, .form textarea { font: inherit; font-size: .98rem; padding: .65rem .75rem; border: 1.5px solid var(--rule); border-radius: 6px; background: #fff; color: var(--ink); width: 100%; }
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(61,111,224,.2); }
.form [aria-invalid="true"] { border-color: var(--against); }
.check { display: flex; gap: .6rem; align-items: center; font-size: .95rem; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--ink); }
.form-foot { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.form-msg { margin: 0; font-size: .93rem; }
.form-msg.ok { color: var(--for); font-weight: 600; }
.form-msg.err { color: var(--against); font-weight: 600; }
.fine { margin: 0; font-size: .82rem; color: var(--graphite); }
.hp { position: absolute; left: -9999px; }
@media (max-width: 860px) { .join { grid-template-columns: 1fr; } .form { grid-template-columns: 1fr; } }

.foot { max-width: var(--max); margin: 0 auto; padding: 2rem var(--gap) 3rem; border-top: 1px solid var(--rule); color: var(--graphite); font-size: .85rem; display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap; }
.foot p { margin: 0; max-width: 70ch; }

@media (prefers-reduced-motion: reduce) {
  .pulse, .feed li.new, .detail .fade-in { animation: none; }
  .g-edge, .g-node circle, .g-node text { transition: none; }
}

/* mobile refinements */
@media (max-width: 760px) {
  .feed { height: auto; }
  .feed li:nth-child(n+5) { display: none; }
  .feed .tag { justify-self: start; }
}
@media (max-width: 560px) {
  #run-graph .g-node text { font-size: 17px; }
  #run-graph { max-height: 300px; }
}
