:root {
  --bg: #0b1020;
  --panel: #141b2e;
  --inner: #0f1628;
  --line: #26304d;
  --text: #e8edf8;
  --dim: #97a3c0;
  --accent: #8ab4ff;
  --up: #ffb86b;
  --down: #5eead4;
  --stale: #fde68a;
  --ok: #86efac;
  --no: #fda4af;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px / 1.45 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover {
  border-color: var(--accent);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
  border-color: var(--line);
}
button.primary {
  background: var(--accent);
  color: #0b1020;
  font-weight: 700;
  border-color: var(--accent);
}
button.quiet {
  color: var(--dim);
}
button.on {
  border-color: var(--accent);
  color: var(--accent);
}

h2 {
  font-size: 12.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 10px;
  font-weight: 600;
}
p.hint {
  color: var(--dim);
  font-size: 12.5px;
  margin: -4px 0 12px;
}

header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand span {
  font-weight: 400;
  color: var(--dim);
  margin-left: 10px;
  font-size: 16px;
}
nav.worlds {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
nav.worlds button {
  border-radius: 999px;
  padding: 7px 14px;
}
.clock {
  color: var(--dim);
  font-size: 14px;
}
#clock {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
}
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.controls a.how {
  font-size: inherit;
  color: var(--dim);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  text-decoration: none;
}
.controls a.how:hover {
  border-color: var(--accent);
  color: var(--text);
}
/* Shown in the guide's own frame, the page needs no way to the guide. */
body.embedded .controls a.how {
  display: none;
}

/* The one sentence that says what this is, and then the situation of the world. */
p.what {
  color: var(--text);
  font-size: 16.5px;
  margin: 14px 22px 0;
  max-width: 980px;
}
p.intro {
  color: var(--dim);
  font-size: 15px;
  margin: 4px 22px 0;
  max-width: 1100px;
}

/* Telling on the left; the sentence, the graph, the why and the actions on the right. */
main.top {
  display: grid;
  grid-template-columns: 372px minmax(0, 1fr);
  gap: 18px;
  padding: 14px 22px 18px;
  align-items: start;
}
.left,
.right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.beside {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}
section.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

/* The sentence at the top: what was just done, what it moved, and what Quorra would do. */
div.caption {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 18px;
  min-height: 64px;
}
.caption .title {
  font-size: 17.5px;
  font-weight: 600;
}
.caption .rest {
  color: var(--dim);
  font-size: 14px;
  margin-top: 6px;
}
.caption .rest.now {
  color: var(--text);
  font-size: 16px;
  margin-top: 8px;
}
.caption .rest.now::first-letter {
  color: var(--ok);
}
.caption .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.caption .chip {
  font-size: 13.5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--inner);
}
.caption .chip b {
  font-variant-numeric: tabular-nums;
}
.caption .offer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* The stage: the questions as cards, and the arrows between them. */
.stage-wrap {
  overflow: hidden;
}
.stage {
  position: relative;
  transform-origin: top left;
  margin: 0 auto;
}
.stage svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.link {
  fill: none;
  stroke: var(--line);
  stroke-width: 2.5;
  marker-end: url(#head);
}
.link.on {
  stroke: var(--accent);
}
#head path {
  fill: var(--line);
}

button.belief {
  position: absolute;
  padding: 8px 13px 10px;
  text-align: left;
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  transition:
    border-color 0.25s,
    box-shadow 0.25s;
}
button.belief:hover {
  border-color: var(--accent);
}
button.belief.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent) inset;
}
button.belief.stale {
  border-color: var(--stale);
}
.belief .name {
  font-size: 13.5px;
  line-height: 1.2;
  color: var(--dim);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.belief .row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 3px 0 6px;
}
.belief .leading {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.belief .pct {
  font-size: 25px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.belief .dir {
  font-size: 13px;
  color: var(--dim);
  width: 12px;
}
.belief .bar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  background: var(--inner);
  overflow: hidden;
  gap: 2px;
}
.belief .bar i {
  display: block;
  height: 100%;
  background: var(--line);
  transition: width 0.45s ease-out;
}
.belief .bar i.lead {
  background: var(--accent);
}
.belief .chips {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  height: 17px;
}
.belief .chip {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
  background: var(--bg);
  white-space: nowrap;
}
.belief .chip.would-be {
  color: var(--down);
  border-color: var(--down);
}
.belief.unsure .leading,
.belief.unsure .pct {
  color: var(--stale);
}
.belief.unsure .chip,
.belief.stale .chip {
  color: var(--stale);
  border-color: var(--stale);
}

/* The two sides of the left panel: telling, and what has been told. */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.tabs button.tab {
  white-space: nowrap;
  font-size: 13.5px;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--dim);
}
.tabs button.tab.on {
  border-color: var(--accent);
  color: var(--text);
}

/* Telling Quorra something. */
.events {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
button.event {
  text-align: left;
  padding: 7px 12px;
  border-left: 3px solid var(--accent);
}
button.event:disabled {
  border-left-color: var(--line);
}
button.event .label {
  display: block;
  font-size: 14px;
  font-weight: 600;
}
button.event .from {
  display: block;
  color: var(--dim);
  font-size: 12px;
  margin-top: 1px;
}
button.wait {
  width: 100%;
  margin-top: 10px;
  border-style: dashed;
  color: var(--dim);
}

/* What has been told, newest first. */
ol.told {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.told:empty::after {
  content: "Nothing yet.";
  color: var(--dim);
  font-size: 14px;
}
li.event {
  border-left: 3px solid var(--accent);
  padding: 7px 10px;
  background: var(--inner);
  border-radius: 6px;
  animation: arrive 0.4s ease-out;
}
li.event .at,
li.event .src {
  display: inline-block;
  color: var(--dim);
  font-size: 12px;
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}
li.event .text {
  display: block;
  font-size: 14px;
}
li.event .note {
  display: inline-block;
  color: var(--stale);
  font-size: 12.5px;
  margin-top: 4px;
}
li.event .do {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
li.event .do button {
  font-size: 12.5px;
  padding: 4px 9px;
}
li.event.taken-back {
  border-left-color: var(--no);
  opacity: 0.75;
}
li.event.taken-back .text {
  text-decoration: line-through;
}
@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Why. */
#why-title {
  text-transform: none;
  letter-spacing: 0;
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
}
.why-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.why-options:empty {
  display: none;
}
.why-options button.option {
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--dim);
}
.why-options .option b {
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}
.why-options .option.on {
  border-color: var(--accent);
  color: var(--text);
}
ol#why {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
#why li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  font-size: 14px;
}
#why li .what {
  color: var(--text);
}
#why li .what small {
  display: block;
  color: var(--dim);
  font-size: 12.5px;
}
/* The raw figure behind a "why" line is shown only under "Advanced". */
#why li .how {
  display: none;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
body.advanced #why li .how {
  display: block;
}
#why li .how.plus {
  color: var(--up);
}
#why li .how.minus {
  color: var(--down);
}
#why li .track {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 999px;
  background: var(--inner);
  overflow: hidden;
}
#why li .track i {
  display: block;
  height: 100%;
}
#why li .track i.plus {
  background: var(--up);
}
#why li .track i.minus {
  background: var(--down);
}
#why li.empty,
#why li.hardly {
  color: var(--dim);
  font-size: 13.5px;
}

/* What Quorra would do. */
.action {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--inner);
  margin-bottom: 8px;
  border: 1px solid var(--line);
}
.action:last-child {
  margin-bottom: 0;
}
.action .line {
  display: flex;
  align-items: center;
  gap: 10px;
}
.action .line .verdict {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
  white-space: nowrap;
}
.action .line .label {
  font-weight: 600;
  font-size: 15px;
}
.action .why {
  color: var(--dim);
  font-size: 13.5px;
  margin-top: 6px;
}
.action .about {
  color: var(--dim);
  font-size: 12.5px;
  margin-top: 4px;
  font-style: italic;
}
.action.yes {
  border-color: var(--ok);
}
.action.yes .line .verdict {
  color: #0b1020;
  background: var(--ok);
  border-color: var(--ok);
}
.action.withheld .line .verdict {
  color: var(--stale);
  border-color: var(--stale);
}

/* The world as data. */
section.editor {
  margin-top: 12px;
}
.editor textarea {
  width: 100%;
  min-height: 460px;
  resize: vertical;
  background: var(--inner);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font:
    13px / 1.5 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
}
.editor .row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
ol.problems {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--no);
  font-size: 14px;
}
.problems:empty {
  display: none;
}

/* Typing a message in one's own words. */
form.typed {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
form.typed label {
  display: block;
  color: var(--dim);
  font-size: 13px;
  margin-bottom: 6px;
}
form.typed textarea {
  width: 100%;
  resize: vertical;
  background: var(--inner);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  font-size: 14.5px;
}
form.typed textarea:disabled {
  opacity: 0.45;
}
.typed .typed-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
}
form.typed .typed-row button {
  white-space: nowrap;
  flex-shrink: 0;
}
.typed .typed-row .hint {
  flex: 1;
  color: var(--dim);
  font-size: 12.5px;
}
div.read-note {
  font-size: 14px;
  margin-top: 8px;
  color: var(--text);
}
.read-note:empty {
  display: none;
}
.read-note button.pick {
  font-size: 13px;
  padding: 4px 10px;
  margin: 4px 6px 0 0;
  border-radius: 999px;
}
.read-note .pick b {
  margin-left: 6px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

footer.under {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 26px;
  color: var(--dim);
  font-size: 13.5px;
  padding: 0 22px 22px;
}
/* "Advanced": the raw figures, the last update's time, and the world as data, folded away. */
details.more {
  margin: 0 22px 22px;
  scroll-margin-top: 10px;
}
details.more > summary {
  cursor: pointer;
  color: var(--dim);
  font-size: 13.5px;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 12px;
  border: 1px solid var(--line);
}
details.more > summary:hover {
  border-color: var(--accent);
  color: var(--text);
}
details.more[open] > summary {
  color: var(--text);
}
details.more .advanced {
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
details.more #timing {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* In a frame beside something else, as in the guide: telling on the left, all else in one column. */
@media (max-width: 1180px) {
  main.top {
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 14px;
    padding: 10px 14px 14px;
  }
  .beside {
    grid-template-columns: 1fr;
  }
  .controls {
    margin-left: 0;
  }
  header {
    gap: 12px;
    padding: 10px 14px;
  }
  p.what,
  p.intro {
    margin-left: 14px;
    margin-right: 14px;
  }
  section.panel {
    padding: 12px;
  }
}
/* Narrow: the graph first, then the telling. */
@media (max-width: 720px) {
  main.top {
    grid-template-columns: 1fr;
  }
  .right {
    order: -1;
  }
}
