/* The try-it demos (tools/tools.js and tools/demos/*.js). Colours come only from the page's tokens, so every demo changes with the
   light and dark looks; the five tones of the imagined people are the faces' own colours, set once for each look below. Sizes under
   1rem carry a 12px floor. Nothing here glows, and nothing moves under reduced motion. */

.demo {
  --tone-0: #2f9e5a;
  --tone-1: #c98f00;
  --tone-2: #e2552b;
  --tone-3: #9a5bd0;
  --tone-4: #2f7fd6;
  --demo-font: var(--font, var(--font-body, system-ui, sans-serif));
  --demo-radius: var(--radius, 14px);
  --demo-radius-sm: var(--radius-sm, 9px);
  --demo-press: 120ms;
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: var(--demo-radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--demo-font);
  font-size: 1rem;
  line-height: 1.5;
  overflow: hidden;
}

:root[data-theme='dark'] .demo {
  --tone-0: #5fcf87;
  --tone-1: #f0c043;
  --tone-2: #ff7a50;
  --tone-3: #b98ae8;
  --tone-4: #5aa6f0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .demo {
    --tone-0: #5fcf87;
    --tone-1: #f0c043;
    --tone-2: #ff7a50;
    --tone-3: #b98ae8;
    --tone-4: #5aa6f0;
  }
}

.tone-0 { background: var(--tone-0); }
.tone-1 { background: var(--tone-1); }
.tone-2 { background: var(--tone-2); }
.tone-3 { background: var(--tone-3); }
.tone-4 { background: var(--tone-4); }

/* ---- The bar: what this is, and a way to start over ---- */

.demo__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 6px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: max(12px, 0.8125rem);
  color: var(--ink-3);
}

.demo__tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--ink);
}

.demo__tag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.demo__note {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo__again {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--demo-radius-sm);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--demo-press) ease, color var(--demo-press) ease;
}

.demo__again:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.demo__stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 18px 20px 20px;
}

@container (max-width: 520px) {
  .demo__note {
    visibility: hidden;
  }

  .demo__stage {
    padding: 14px 14px 16px;
  }
}

/* ---- Buttons ---- */

.demo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--demo-radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: max(12px, 0.9375rem);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--demo-press) ease, border-color var(--demo-press) ease, transform var(--demo-press) ease;
}

.demo-btn:hover:not(:disabled) {
  border-color: var(--ink-3);
}

.demo-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.demo-btn--primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

.demo-btn--primary:hover:not(:disabled) {
  border-color: transparent;
  background: color-mix(in srgb, var(--accent) 88%, var(--ink));
}

.demo-btn:disabled,
.chat__choice:disabled {
  opacity: 0.55;
  cursor: default;
}

/* a waiting coral button is drawn plain, not as a faded coral (which reads as broken) */
.demo-btn--primary:disabled {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink-3);
  opacity: 1;
}

.demo button:focus-visible,
.demo input:focus-visible,
.demo [tabindex='-1']:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---- An imagined person: a dot, a first name, the word imagined ---- */

.person {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.person__dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.person__name {
  font-weight: 600;
  color: var(--ink);
}

.person__tag {
  font-size: max(12px, 0.8125rem);
  color: var(--ink-3);
}

/* ---- Chat ---- */

.chat__head {
  display: flex;
  align-items: center;
  font-size: max(12px, 0.8125rem);
  color: var(--ink-2);
}

.chat__project {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chat__project-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--accent);
}

.chat__thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 8rem;
  max-height: 24rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.chat__msg {
  max-width: min(88%, 38rem);
  line-height: 1.5;
}

.chat__text,
.chat__next,
.chat__aside {
  margin: 0;
}

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

.chat__msg--you {
  align-self: flex-end;
  padding: 9px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 14px 14px 4px 14px;
  background: var(--surface-2);
  color: var(--ink);
}

.chat__msg--cofounder {
  position: relative;
  align-self: flex-start;
  padding-left: 22px;
  color: var(--ink);
}

.chat__msg--cofounder::before {
  content: '';
  position: absolute;
  top: calc(0.75em - 4.5px);
  left: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.chat__next {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-weight: 600;
}

.chat__next:empty {
  display: none;
}

.chat__aside {
  margin-top: 8px;
  font-size: max(12px, 0.8125rem);
  color: var(--ink-3);
}

.chat__thinking {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink-3);
  vertical-align: middle;
  animation: demo-breathe 0.9s ease-in-out infinite alternate;
}

.is-thinking::before {
  opacity: 0.4;
}

@keyframes demo-breathe {
  from { opacity: 0.25; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.chat__choices {
  display: grid;
  gap: 8px;
}

.chat__choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--demo-radius-sm);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: max(12px, 0.9375rem);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--demo-press) ease, border-color var(--demo-press) ease;
}

.chat__choice::after {
  content: '\2192';
  color: var(--ink-3);
  transition: transform var(--demo-press) ease, color var(--demo-press) ease;
}

.chat__choice:hover:not(:disabled) {
  border-color: var(--ink-3);
  background: var(--surface-2);
}

.chat__choice:hover:not(:disabled)::after {
  color: var(--accent-text);
  transform: translateX(2px);
}

.chat__done {
  margin: 0;
  font-size: max(12px, 0.875rem);
  color: var(--ink-3);
}

.chat__form {
  display: flex;
  gap: 8px;
}

.chat__form[hidden] {
  display: none;
}

.chat__input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--demo-radius-sm);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}

.chat__input::placeholder {
  color: var(--ink-3);
}

/* ---- Crowd simulator (its picture is demos/crowd.css's) ---- */

.crowd__intro,
.demo-intro {
  margin: 0;
  color: var(--ink-2);
}

.crowd__way {
  font-size: max(12px, 0.8125rem);
  font-weight: 600;
  color: var(--ink-2);
}

.crowd__line {
  margin: 4px 0 0;
  font-weight: 600;
  color: var(--ink);
}

.crowd__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

/* The Run button keeps one width while the crowd reacts: wide enough for its longer running words and their dot (measured: 17.3em),
   so the note beside it never moves or rewraps mid-run. */
.crowd__run {
  min-width: min(100%, 17.5em);
}

.demo [hidden] {
  display: none !important;
}

/* while the crowd reacts, the button says so and breathes, at full strength (a faded coral reads as broken) */
.crowd__run:disabled,
.demo-btn--busy:disabled {
  gap: 10px;
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  opacity: 1;
}

.crowd__run:disabled::before,
.demo-btn--busy:disabled::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: demo-breathe 0.9s ease-in-out infinite alternate;
}

.crowd__caution,
.demo-caution {
  flex: 1 1 14rem;
  margin: 0;
  font-size: max(12px, 0.8125rem);
  color: var(--ink-3);
}

.crowd__feed,
.feed {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.crowd__feed:empty,
.feed:empty {
  display: none;
}

.crowd__item,
.feed__item {
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--demo-radius-sm);
  background: var(--bg);
}

/* (the crowd's items settle in by its own stylesheet) */
.feed__item {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.feed__item.is-in {
  opacity: 1;
  transform: none;
}

.crowd__who,
.feed__who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
}

.crowd__lean,
.feed__note {
  font-size: max(12px, 0.8125rem);
  color: var(--ink-3);
}

.crowd__says,
.feed__says {
  margin: 6px 0 0;
  color: var(--ink);
}

.crowd__result {
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--demo-radius-sm);
  background: var(--surface);
}

.crowd__result[hidden] {
  display: none;
}

.crowd__verdict,
.result__title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--ink);
}

.crowd__summary {
  margin: 4px 0 0;
  color: var(--ink-2);
}

.crowd__next {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  font-size: max(12px, 0.875rem);
  color: var(--ink-2);
}

/* ---- Shared by plan, notes, data, pitch and pre-mortem: two columns where there is room, a card, a list with dots ---- */

.split {
  display: grid;
  gap: 18px;
  align-items: start;
}

@container (min-width: 640px) {
  .split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
  }
}

.card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--demo-radius-sm);
  background: var(--surface);
  transition: border-color 200ms ease;
}

.feed {
  margin: 0;
}

.result__title {
  margin-bottom: 8px;
}

.dots-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dots-list li {
  position: relative;
  padding-left: 18px;
}

.dots-list li::before,
.plan__pip,
.notes__leader {
  content: '';
  position: absolute;
  top: 0.62em;
  left: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---- Plan ---- */

.plan__chat {
  display: grid;
  gap: 14px;
}

.plan__thread {
  min-height: 0;
}

.plan__head {
  display: grid;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.plan__title {
  font-weight: 700;
}

.plan__meter {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: max(12px, 0.8125rem);
  color: var(--ink-3);
}

.plan__pips {
  display: inline-flex;
  gap: 5px;
}

.plan__pip {
  position: static;
  background: var(--line);
  transition: background-color 200ms ease;
}

.plan__pip.is-on {
  background: var(--accent);
}

.is-complete .plan__word {
  color: var(--accent-text);
}

.plan__steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plan__step {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 240ms ease, transform 240ms ease;
}

.plan__step.is-in {
  opacity: 1;
  transform: none;
}

.plan__label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}

.plan__check {
  flex: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 2px solid var(--ink-3);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color var(--demo-press) ease, border-color var(--demo-press) ease;
}

.plan__check:checked {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.is-done .plan__text {
  color: var(--ink-3);
  text-decoration: line-through;
}

.plan__empty {
  padding: 18px 0 6px;
  color: var(--ink-3);
}

.plan__hint {
  margin-top: 12px;
}

/* ---- Notes ---- */

.notes__map {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 0 auto;
}

.notes__grid {
  display: grid;
  gap: 10px;
}

@container (min-width: 560px) {
  .notes__grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.notes__card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notes__card.is-picked,
.notes__card.is-shown {
  border-color: var(--accent);
}

.notes__card:focus {
  outline: none;
}

.notes__title,
.notes__backlink {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.notes__body {
  flex: 1;
  color: var(--ink-2);
}

.notes__back {
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.notes__back-head,
.data__meta,
.pitch__label,
.premortem__key {
  font-size: max(12px, 0.8125rem);
  color: var(--ink-3);
}

.notes__backlink {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.notes__backlink:hover {
  color: var(--accent-text);
}

.notes__leader {
  position: static;
  width: 22px;
  height: 0;
  border-radius: 0;
  border-top: 3px dotted var(--accent);
  background: none;
}

.notes__press {
  align-self: flex-start;
}

.is-picking .notes__card:not(.is-picked) .notes__press {
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ---- Your data ---- */

.data__list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.data__row,
.data__file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 44px;
  border-bottom: 1px solid var(--line-soft);
}

.data__file {
  width: 100%;
  padding: 0 8px;
  border-width: 0 0 1px;
  border-radius: var(--demo-radius-sm) var(--demo-radius-sm) 0 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.data__file:hover,
.data__file[aria-pressed='true'] {
  background: var(--surface-2);
}

.data__name {
  flex: none;
  font-weight: 600;
}

.data__name--file,
.data__label,
.data__text {
  font-size: max(12px, 0.875rem);
  font-weight: 400;
}

.data__name--file {
  font-weight: 600;
}

.data__meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data__label {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-3);
}

.data__text {
  margin: 10px 0 0;
  white-space: pre-wrap;
  color: var(--ink);
}

/* ---- Pitch panel and pre-mortem ---- */

.pitch__line,
.premortem__title {
  font-weight: 700;
}

.pitch__prove,
.premortem__signs {
  display: grid;
  gap: 10px;
}

.premortem__intro {
  font-weight: 600;
  color: var(--ink);
}

.premortem__said {
  display: grid;
  gap: 8px;
  margin: 8px 0 10px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line-soft);
  list-style: none;
  font-size: max(12px, 0.875rem);
  color: var(--ink-2);
}

.premortem__reason {
  display: grid;
  gap: 2px;
}

.premortem__line {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.premortem__key {
  font-weight: 600;
  line-height: 1.85;
}

.plan__chat .demo-btn {
  justify-self: start;
}

.demo__stage > .demo-btn {
  align-self: flex-start;
}

/* ---- Time stopped, and less motion ---- */

[data-paused] .demo * {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .demo *,
  .demo *::before,
  .demo *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .person__dot,
  .demo__tag::before,
  .chat__msg--cofounder::before,
  .dots-list li::before,
  .plan__pip.is-on {
    forced-color-adjust: none;
    background: CanvasText;
  }

  .notes__card.is-picked {
    border-color: Highlight;
  }
}

/* ---- The Tools page's own layout (the page around the boxes) ---- */

.tool__demo {
  min-height: 360px;
}

.tool__fallback {
  margin: 0;
  padding: 1.25rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius, 14px);
  color: var(--ink-3);
}

/* With scripts on, the line for a browser without them is not true: the box keeps its quiet room while its demo loads, and shows
   the line again only once it says the demo did not load (tools.js, waitlist.js). */
.js .tool__demo:not([data-state='failed']) .tool__fallback {
  visibility: hidden;
}

@media (max-width: 600px) {
  .demo,
  .tool__demo {
    min-height: 320px;
  }
}

@media (min-width: 1921px) {
  .page--tools {
    max-width: calc(70rem + 2 * var(--gutter));
  }
}
