* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2rem 1.25rem 4rem;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.page-head,
.flow {
  max-width: 60rem;
  margin: 0 auto;
}

.muted {
  color: var(--ink-muted);
}

code {
  font-size: 0.9em;
}

/* Head */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

h1 {
  margin: 1.25rem 0 0.4rem;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.lead {
  max-width: 38rem;
  margin: 0 0 1.25rem;
  color: var(--ink-muted);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.per-legend {
  margin-top: 0.5rem;
}

.legend .sep {
  width: 1px;
  height: 1rem;
  background: var(--line);
}

.mini {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid var(--ink-muted);
}

.mini.event {
  border-radius: 50%;
}

.mini.task {
  width: 1.2rem;
  border-radius: 0.3rem;
}

.mini.gateway {
  width: 0.7rem;
  height: 0.7rem;
  transform: rotate(45deg);
}

/* Who does a task: a colored chip. */
.person { --lane: var(--lane-person); }
.voyage { --lane: var(--lane-voyage); }
.jev { --lane: var(--lane-jev); }
.code { --lane: var(--lane-code); }
.data { --lane: var(--lane-data); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  padding: 0.1rem 0.55rem 0.1rem 0.45rem;
  border-radius: 1rem;
  background: color-mix(in srgb, var(--lane) 16%, transparent);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--lane);
}

/* Flow */

.flow {
  --gap: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 2.5rem;
}

.card {
  display: grid;
  gap: 0.3rem;
  align-content: start;
  justify-items: start;
  width: 100%;
  padding: 0.8rem 0.9rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--card);
  box-shadow: 0 1px 3px var(--shadow);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.card:hover {
  border-color: var(--lane);
  transform: translateY(-1px);
}

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card strong {
  font-size: 0.95rem;
  line-height: 1.3;
}

.card small {
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.card.jev {
  border-color: color-mix(in srgb, var(--lane) 45%, var(--line));
  background: color-mix(in srgb, var(--lane) 6%, var(--card));
}

/* Built beforehand, not per question. */
.card.data {
  border-style: dashed;
  box-shadow: none;
  background: transparent;
}

.single {
  width: min(22rem, 100%);
}

.event {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1.1rem 0.45rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 2rem;
  background: var(--card);
  box-shadow: 0 1px 3px var(--shadow);
  font-weight: 600;
  text-align: left;
}

.ring {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--lane);
  border-radius: 50%;
}

.event.end .ring {
  border-width: 5px;
}

/* Connectors */

.link {
  position: relative;
  justify-self: center;
  width: 2px;
  height: 1.5rem;
  background: var(--line);
}

.link:not(.plain)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -4px;
  border: 5px solid transparent;
  border-top-color: var(--ink-muted);
  border-bottom: none;
}

.through {
  justify-self: center;
  width: 2px;
  background: var(--line);
}

/* One line splitting into the three sources, and joining again. The lane
   centres sit a sixth of the width in from each side, less the gaps. */
.fan {
  --side: calc((100% - 2 * var(--gap)) / 6);
  position: relative;
  width: 100%;
  height: 2.6rem;
}

.fan .bar {
  position: absolute;
  left: var(--side);
  right: var(--side);
  height: 50%;
  border: 2px solid var(--line);
}

.fan::before,
.fan .mid {
  content: "";
  position: absolute;
  left: calc(50% - 1px);
  width: 2px;
  height: 50%;
  background: var(--line);
}

.fan.out::before {
  top: 0;
}

.fan.out .bar,
.fan.out .mid {
  bottom: 0;
}

.fan.out .bar {
  border-bottom: none;
  border-radius: 0.8rem 0.8rem 0 0;
}

.fan.in .bar,
.fan.in .mid {
  top: 0;
}

.fan.in .bar {
  border-top: none;
  border-radius: 0 0 0.8rem 0.8rem;
}

.fan.in::before {
  bottom: 0;
}

.fan .head {
  position: absolute;
  bottom: 0;
  border: 5px solid transparent;
  border-top-color: var(--ink-muted);
  border-bottom: none;
  transform: translateX(-5px);
}

.fan .head.left { left: calc(var(--side) + 1px); }
.fan .head.centre { left: 50%; }
.fan .head.right { left: calc(100% - var(--side) - 1px); }

.lanes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 var(--gap);
  width: 100%;
}

.lane-title {
  margin: 0 0 0.6rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* A decision: yes goes on down, no ends to the side. */
.gateway {
  position: relative;
  display: grid;
  justify-items: center;
  padding-top: 0.2rem;
}

.diamond {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--lane-code);
  background: var(--card);
  transform: rotate(45deg);
}

/* The turned square reaches past its box; this lets the arrows meet its corners. */
.link.to-gateway {
  margin-bottom: 0.15rem;
}

.gateway .no {
  position: absolute;
  top: 0.35rem;
  left: calc(50% + 0.9rem);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--ink-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.gateway .no i {
  width: 1.1rem;
  height: 2px;
  background: var(--line);
}

/* An end event: a thick ring. */
.stop {
  width: 0.8rem;
  height: 0.8rem;
  border: 3px solid var(--ink-muted);
  border-radius: 50%;
}

/* What a step runs once for, in the card's corner, like BPMN's multi-instance marker. */
.card {
  position: relative;
}

.per {
  position: absolute;
  top: 0.75rem;
  right: 0.8rem;
  display: flex;
  gap: 0.2rem;
  color: var(--ink-muted);
}

.per svg,
.per-icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

/* Side panel */

dialog {
  width: min(34rem, 100%);
  height: 100%;
  max-height: 100%;
  margin: 0 0 0 auto;
  padding: 1.25rem 1.4rem 2rem;
  border: none;
  border-left: 1px solid var(--line);
  /* Stands off from the page in both themes, where paper would merge with it. */
  box-shadow: -8px 0 32px var(--shadow);
  background: var(--paper);
  color: var(--ink);
}

dialog::backdrop {
  background: var(--backdrop);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

#panel-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
}

.close {
  flex: none;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

#panel-body {
  font-size: 0.92rem;
}

.facts {
  display: grid;
  grid-template-columns: minmax(6rem, auto) 1fr;
  gap: 0.6rem 1rem;
  margin: 1rem 0 0;
}

.facts dt {
  color: var(--ink-muted);
  font-size: 0.8rem;
  padding-top: 0.1rem;
}

.facts dd {
  margin: 0;
}

.embedding {
  margin: 1rem 0 0;
}

.embedding svg {
  display: block;
  width: 100%;
  max-width: 24rem;
  height: auto;
}

.embedding figcaption {
  margin-top: 0.4rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.embedding .plane {
  fill: var(--card);
  stroke: var(--line);
}

.embedding .label {
  fill: var(--ink-muted);
  font-size: 11px;
}

.embedding .label.strong {
  fill: var(--ink);
  font-weight: 700;
}

.embedding .you {
  fill: var(--lane-voyage);
}

.embedding .near {
  fill: color-mix(in srgb, var(--lane-voyage) 55%, var(--card));
}

.embedding .far {
  fill: var(--line);
}

.embedding .reach {
  stroke: var(--lane-voyage);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

/* Explainers: buttons in the color of what they explain, apart from the legend. */
.term {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.95rem 0.45rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--lane, var(--accent)) 50%, var(--line));
  border-radius: 1.5rem;
  background: color-mix(in srgb, var(--lane, var(--accent)) 12%, var(--card));
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.term::before {
  content: "?";
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--lane, var(--accent));
  color: var(--paper);
  font-size: 0.8rem;
  font-weight: 800;
}

.term:hover {
  border-color: var(--lane, var(--accent));
  transform: translateY(-1px);
}

.terms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 1.5rem;
}

/* Beside the diamond the term stays quiet: the flow comes first. */
.gateway .term {
  gap: 0.3rem;
  margin-top: 0.3rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 400;
}

.gateway .term::before {
  width: 0.85rem;
  height: 0.85rem;
  font-size: 0.55rem;
}

.gateway .term:hover {
  color: var(--ink);
}

#panel-body > .term {
  margin-top: 1rem;
}

/* Jev's request, drawn as if we had to answer it. */
.meta {
  margin: 1.5rem 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.person-card {
  display: grid;
  gap: 0.35rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--card);
}

.person-card p {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
}

.hint {
  margin: 0.6rem 0 0;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.hint i,
.fields i {
  font-style: normal;
  color: var(--ink-muted);
}

.hint i {
  font-weight: 700;
}

#panel-body > .items {
  margin-top: 0.8rem;
}

.groups {
  display: grid;
  gap: 0.6rem;
}

.party {
  margin: 0.8rem 0 0.35rem;
  font-weight: 700;
}

.items,
.questions,
.choice,
.score {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.item {
  display: grid;
  gap: 0.25rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: var(--card);
}

.item p {
  margin: 0;
}

.fields {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.75rem;
  font-size: 0.78rem;
}

.fields code {
  font-weight: 700;
}

.questions {
  gap: 0.9rem;
}

.question {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem 0.8rem 0.8rem;
  border: 1px solid color-mix(in srgb, var(--lane-jev) 35%, var(--line));
  border-radius: 0.9rem;
  background: var(--card);
}

.question > p {
  margin: 0;
}

.type {
  color: var(--ink-muted);
}

.answer {
  display: grid;
  gap: 0.5rem;
  padding: 0.65rem 0.7rem 0.7rem;
  border-radius: 0.65rem;
  background: color-mix(in srgb, var(--lane-jev) 9%, var(--card));
}

.example {
  width: fit-content;
  padding: 0 0.45rem;
  border: 1px dashed color-mix(in srgb, var(--lane-jev) 60%, var(--line));
  border-radius: 1rem;
  color: var(--ink-muted);
  font-size: 0.7rem;
}

/* A 0–1 bar: --value fills it, --covered marks the threshold. */
.meter {
  position: relative;
  display: block;
  height: 0.55rem;
  border-radius: 1rem;
  background: var(--line);
}

.meter .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--value) * 100%);
  border-radius: inherit;
  background: var(--lane-jev);
}

.meter .mark {
  position: absolute;
  top: -0.25rem;
  bottom: -0.25rem;
  left: calc(var(--covered, 0.5) * 100% - 1px);
  width: 2px;
  background: var(--ink);
}

.noul {
  display: grid;
  gap: 0.35rem;
}

.reading {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.85rem;
}

.reading strong {
  font-size: 1rem;
}

.kept,
.dropped {
  font-size: 0.75rem;
  font-weight: 600;
}

.kept {
  color: var(--agree-strong);
}

.dropped {
  color: var(--ink-muted);
  text-decoration: line-through;
}

/* One row per option: what it means, and how likely Jev finds it. */
.choice li,
.score li {
  display: grid;
  grid-template-columns: 1fr 5.5rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.choice li strong,
.score li strong {
  color: var(--ink);
}

.choice li.picked,
.score li.picked {
  border-color: var(--lane-jev);
  background: var(--card);
  color: var(--ink);
}

.share {
  display: grid;
  gap: 0.2rem;
  justify-items: end;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.share .meter {
  width: 100%;
  height: 0.35rem;
}

.share .mark {
  display: none;
}

/* The five levels keep the colors the app gives them. */
.score li strong::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: var(--level);
}

.score li:nth-child(1) { --level: var(--disagree-strong); }
.score li:nth-child(2) { --level: var(--disagree); }
.score li:nth-child(3) { --level: var(--neutral); }
.score li:nth-child(4) { --level: var(--agree); }
.score li:nth-child(5) { --level: var(--agree-strong); }

.request summary {
  margin-top: 1.5rem;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.85rem;
}

.request pre {
  overflow: auto;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--card);
  font-size: 0.72rem;
  white-space: pre-wrap;
}

@media (max-width: 44rem) {
  body {
    padding: 1.25rem 0.75rem 3rem;
  }

  .flow {
    --gap: 0.5rem;
  }

  .lanes .card {
    padding: 0.6rem;
  }

  .lanes .card strong {
    font-size: 0.8rem;
  }

  .lanes .card small,
  .gateway .term {
    display: none;
  }

  /* Narrow cards have no room beside the chip. */
  .lanes .per {
    position: static;
  }

  .lanes .chips .chip.voyage {
    display: none;
  }

  .gateway .no {
    left: calc(50% + 0.8rem);
    font-size: 0.65rem;
  }

  .gateway .no i {
    width: 0.5rem;
  }

  .gateway .no-text {
    display: none;
  }

  .lanes .chip {
    gap: 0.25rem;
    padding: 0.1rem 0.4rem 0.1rem 0.3rem;
    font-size: 0.6rem;
  }

  .gateway {
    font-size: 0.72rem;
  }

  .lane-title {
    font-size: 0.62rem;
    letter-spacing: 0.02em;
  }

  .legend .sep {
    display: none;
  }

  .choice li,
  .score li {
    grid-template-columns: 1fr 3.5rem;
    gap: 0.5rem;
  }

}

.lead-in {
  margin: 0.25rem 0 1rem;
}

.kind {
  margin: 0 0 0.5rem;
  font-weight: 700;
}

/* What the app makes of an answer: the number it goes on with. */
.outcome {
  margin: 0.2rem 0 0.7rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.outcome strong {
  margin-right: 0.2rem;
  color: var(--ink);
  font-size: 1.15rem;
}

/* The part of the flow that runs once per topic, as a BPMN multi-instance subprocess. */
.per-topic {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 2.4rem 1rem 0.5rem;
  border: 1.5px dashed var(--line);
  border-radius: 1.2rem;
}

.frame-label {
  position: absolute;
  top: 0.7rem;
  left: 1rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

@media (max-width: 44rem) {
  .per-topic {
    padding: 2.4rem 0.4rem 0.4rem;
  }
}
