:root {
  color-scheme: light;
  --paper: #fafaf7;
  --paper-soft: #f5f5f1;
  --ink: #101115;
  --ink-soft: #383a3f;
  --muted: #707278;
  --rule: #b9bab7;
  --rule-soft: #d9dad6;
  --display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
  --sans: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", "Roboto Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
output { font: inherit; }

button { color: inherit; }

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.trial-page {
  display: grid;
  height: 100svh;
  min-height: 100svh;
  grid-template-rows: 4.75rem minmax(0, 1fr) 5.75rem;
  overflow: hidden;
}

.trial-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  margin: 0 1.9rem;
  border-bottom: 1px solid var(--ink);
}

.trial-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--ink);
  text-decoration: none;
}

.trial-brand img {
  width: 1.85rem;
  height: 1.85rem;
}

.trial-brand span {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.trial-header-note {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.trial-workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(22rem, 29rem) minmax(0, 1fr);
}

.conversation-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.7rem 1.8rem 1.2rem;
  border-right: 1px solid var(--rule);
  overflow-y: auto;
}

.conversation-intro h1,
.map-empty h2,
.handoff-panel h2,
.handoff-panel h3,
.package-dialog h2,
.graph-node h3 {
  font-family: var(--display);
  font-weight: 600;
}

.conversation-intro h1 {
  max-width: 24rem;
  margin: 0;
  font-size: clamp(2rem, 2.5vw, 2.4rem);
  letter-spacing: -0.055em;
  line-height: 0.97;
}

.conversation-intro > p {
  max-width: 23rem;
  margin: 0.7rem 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

.trial-summary {
  display: grid;
  min-height: 4rem;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.65rem 0.8rem 0.65rem 1rem;
  border: 1px solid var(--rule);
}

.trial-summary > p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.73rem;
  line-height: 1.45;
}

.trial-timer {
  display: flex;
  min-width: 4.1rem;
  flex-direction: column;
  align-items: flex-end;
}

.trial-timer strong {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1;
}

.trial-timer span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.62rem;
}

.voice-console {
  display: grid;
  height: clamp(13rem, 31vh, 18rem);
  min-height: 13rem;
  flex: 0 1 18rem;
  grid-template-rows: 4.35rem minmax(0, 1fr);
  border: 1px solid var(--rule);
  background: rgb(255 255 255 / 24%);
}

.voice-presence {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--rule-soft);
}

.voice-presence > svg {
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
  stroke-width: 1.8;
}

.waveform {
  display: flex;
  width: 100%;
  height: 2.1rem;
  align-items: center;
  gap: 0.18rem;
}

.waveform span {
  width: 0.14rem;
  height: calc(0.22rem + (var(--bar, 2) * 0.15rem));
  border-radius: 1px;
  background: var(--ink);
  transform-origin: center;
}

.waveform span:nth-child(5n + 1) { --bar: 2; }
.waveform span:nth-child(5n + 2) { --bar: 5; }
.waveform span:nth-child(5n + 3) { --bar: 8; }
.waveform span:nth-child(5n + 4) { --bar: 4; }
.waveform span:nth-child(5n) { --bar: 6; }

[data-phase="active"] .waveform span,
[data-phase="connecting"] .waveform span {
  animation: voice-wave 820ms ease-in-out infinite alternate;
  animation-delay: calc(var(--bar) * -70ms);
}

.transcript {
  min-height: 0;
  padding: 0.8rem 1rem;
  overflow-y: auto;
  scrollbar-color: var(--ink) transparent;
  scrollbar-width: thin;
}

.transcript-empty {
  display: flex;
  height: 100%;
  min-height: 7rem;
  flex-direction: column;
  justify-content: center;
  color: var(--ink-soft);
}

.transcript-empty strong { font-size: 0.8rem; }

.transcript-empty p {
  max-width: 19rem;
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.transcript-turn + .transcript-turn { margin-top: 0.8rem; }

.transcript-turn header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.transcript-turn strong { font-size: 0.73rem; }

.transcript-turn time {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.56rem;
}

.transcript-turn p {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
}

.trial-error {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--ink);
  font-size: 0.73rem;
  line-height: 1.4;
}

.interview-button,
.handoff-primary,
.handoff-secondary {
  display: inline-flex;
  min-height: 3.25rem;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.045em;
}

.interview-button {
  width: 100%;
  background: var(--ink);
  color: var(--paper);
}

.interview-button:hover { background: var(--ink-soft); }

.interview-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.interview-button svg {
  width: 1.1rem;
  height: 1.1rem;
}

[data-phase="active"] .interview-button {
  background: transparent;
  color: var(--ink);
}

[data-phase="active"] .interview-button svg {
  fill: currentColor;
  stroke: none;
}

.section-label {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.listening-block { margin-top: auto; }

.listening-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 0.55rem;
  border: 1px solid var(--rule);
}

.listening-grid > div {
  display: flex;
  min-width: 0;
  min-height: 4.2rem;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.55rem 0.35rem;
  text-align: center;
}

.listening-grid > div + div { border-left: 1px solid var(--rule); }

.listening-grid svg {
  width: 1rem;
  height: 1rem;
}

.listening-grid span {
  max-width: 7rem;
  font-size: 0.61rem;
  line-height: 1.3;
}

.map-panel {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 3.75rem 3.5rem minmax(0, 1fr) 3.1rem;
  overflow: hidden;
}

.map-tabs-row,
.map-heading-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.55rem;
  border-bottom: 1px solid var(--rule-soft);
}

.map-tabs {
  display: flex;
  height: 100%;
  align-items: stretch;
  gap: 0.2rem;
}

.map-tabs button {
  position: relative;
  min-width: 7rem;
  padding: 0 0.8rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.76rem;
}

.map-tabs button[aria-selected="true"] { font-weight: 750; }

.map-tabs button[aria-selected="true"]::after {
  position: absolute;
  right: 0.55rem;
  bottom: -1px;
  left: 0.55rem;
  height: 3px;
  background: var(--ink);
  content: "";
}

.map-status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  white-space: nowrap;
}

.map-status-mark {
  width: 0.85rem;
  height: 0.85rem;
  border: 1px dotted currentColor;
  border-radius: 50%;
}

[data-phase="active"] .map-status-mark,
[data-phase="connecting"] .map-status-mark {
  border-style: solid;
  border-right-color: transparent;
  animation: spin 800ms linear infinite;
}

[data-phase="complete"] .map-status-mark {
  border-radius: 0;
  background: var(--ink);
}

.map-heading-row { border-bottom: 0; }

.map-controls {
  display: flex;
  align-items: center;
  border: 1px solid var(--rule);
}

.map-controls button,
.map-controls output {
  display: inline-grid;
  width: 2.4rem;
  height: 2.2rem;
  place-items: center;
  border: 0;
  border-right: 1px solid var(--rule);
  background: transparent;
  font-size: 0.77rem;
}

.map-controls button { cursor: pointer; }
.map-controls button:last-child { border-right: 0; }
.map-controls output { width: 3.4rem; }
.map-controls svg { width: 1rem; height: 1rem; }

.map-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: clamp(1.5rem, 4vw, 4rem);
  overflow: auto;
  overscroll-behavior: contain;
}

.map-empty {
  display: grid;
  width: min(33rem, 80%);
  height: 100%;
  min-height: 16rem;
  grid-template-columns: auto 1fr;
  align-content: center;
  gap: 1.25rem;
  margin: 0 auto;
  color: var(--muted);
}

.map-empty-number {
  padding-top: 0.25rem;
  font-family: var(--mono);
  font-size: 0.68rem;
}

.map-empty h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  letter-spacing: -0.045em;
}

.map-empty p {
  max-width: 26rem;
  margin: 0.7rem 0 0;
  font-size: 0.84rem;
  line-height: 1.55;
}

.graph-track {
  --graph-scale: 1;
  display: flex;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  transform: scale(var(--graph-scale));
  transform-origin: center;
  transition: transform 180ms ease;
}

.graph-track > svg {
  width: auto;
  min-width: min(42rem, 100%);
  max-width: none;
  height: auto;
  max-height: 27rem;
  overflow: visible;
}

.graph-track .node rect,
.graph-track .node polygon,
.graph-track .node circle,
.graph-track .node ellipse {
  rx: 0 !important;
  ry: 0 !important;
}

.graph-track .nodeLabel,
.graph-track .label { font-family: var(--display) !important; }

.graph-node {
  width: 11.5rem;
  min-height: 10.5rem;
  padding: 1.2rem 1.1rem 1rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  animation: node-in 280ms ease both;
}

.graph-node[data-category="pain"] { border-style: dashed; }

.graph-node[data-category="outcome"] {
  background: var(--ink);
  color: var(--paper);
}

.graph-node h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
}

.graph-node p {
  margin: 0.7rem 0 1rem;
  font-size: 0.7rem;
  line-height: 1.5;
}

.graph-node small {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: auto;
  font-size: 0.61rem;
}

.graph-node small::before {
  width: 0.62rem;
  height: 0.62rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  content: "";
}

.graph-connector {
  position: relative;
  width: 3.4rem;
  height: 1px;
  flex: 0 0 auto;
  background: var(--ink);
}

.graph-connector::after {
  position: absolute;
  top: -0.26rem;
  right: -1px;
  width: 0.5rem;
  height: 0.5rem;
  border-top: 1px solid var(--ink);
  border-right: 1px solid var(--ink);
  content: "";
  transform: rotate(45deg);
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0 1.7rem;
  border-top: 1px solid var(--rule-soft);
  color: var(--ink-soft);
  font-size: 0.59rem;
}

.map-legend span { display: inline-flex; align-items: center; gap: 0.42rem; }
.map-legend i { width: 0.65rem; height: 0.65rem; border: 1px solid var(--ink); }
.legend-solid { background: var(--ink); }
.legend-progress { border-style: dotted !important; border-radius: 50%; }
.legend-outline { border-radius: 50%; }

.trial-progress {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 1.5rem;
  padding: 0 4.5rem;
  border-top: 1px solid var(--rule);
}

.trial-progress > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.8rem;
  color: var(--muted);
}

.trial-progress > div > span {
  display: grid;
  width: 1.65rem;
  height: 1.65rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 0.65rem;
}

.trial-progress p {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0;
}

.trial-progress strong {
  color: var(--ink);
  font-size: 0.72rem;
}

.trial-progress small { font-size: 0.63rem; }

.trial-progress > svg {
  width: 1.3rem;
  height: 1.3rem;
}

.trial-progress .is-active > span,
.trial-progress .is-complete > span {
  border-color: var(--ink);
  color: var(--ink);
}

.trial-progress .is-complete > span::after { content: "✓"; }
.trial-progress .is-complete > span { font-size: 0; }
.trial-progress .is-complete { color: var(--ink-soft); }

.handoff-panel {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(48rem, 52vw);
  border-left: 1px solid var(--ink);
  background: var(--paper);
  box-shadow: -2rem 0 4rem rgb(16 17 21 / 8%);
}

.handoff-close {
  position: absolute;
  z-index: 1;
  top: 1.25rem;
  right: 1.4rem;
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--display);
  font-size: 1.8rem;
  line-height: 1;
}

.handoff-scroll {
  height: 100%;
  padding: 4.1rem clamp(1.5rem, 3vw, 3rem) 1.6rem;
  overflow-y: auto;
}

.handoff-panel h2 {
  max-width: 34rem;
  margin: 0;
  font-size: clamp(2.2rem, 3.3vw, 3.55rem);
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.handoff-lede {
  margin: 0.65rem 0 1rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.handoff-panel section {
  padding: 0.9rem 0;
  border-top: 1px solid var(--rule);
}

.handoff-panel h3 {
  margin: 0;
  font-size: 1.05rem;
}

.handoff-panel section p,
.handoff-panel li {
  font-size: 0.75rem;
  line-height: 1.5;
}

.handoff-panel section p { margin: 0.45rem 0 0; }
.handoff-panel ul,
.handoff-panel ol { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.handoff-panel li + li { margin-top: 0.3rem; }

.handoff-split {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 1.5rem;
}

.handoff-split > div + div {
  padding-left: 1.5rem;
  border-left: 1px solid var(--rule);
}

.check-list { list-style: none; padding-left: 0 !important; }
.check-list li::before { margin-right: 0.55rem; content: "✓"; }

.package-list { margin-top: 0.55rem; border: 1px solid var(--rule); }

.package-list button {
  display: flex;
  width: 100%;
  min-height: 2.2rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0.75rem;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.package-list button:last-child { border-bottom: 0; }
.package-list button:hover { background: var(--paper-soft); }
.package-list button span:first-child { font-size: 0.72rem; }
.package-list button span:last-child { color: var(--muted); font-size: 0.6rem; }

.handoff-primary,
.handoff-secondary { width: 100%; }

.handoff-primary {
  margin-top: 0.25rem;
  background: var(--ink);
  color: var(--paper);
}

.handoff-secondary { margin-top: 0.55rem; background: transparent; }

.handoff-disclosure {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.63rem;
}

.package-dialog {
  width: min(58rem, calc(100vw - 2rem));
  max-height: min(44rem, calc(100vh - 2rem));
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
}

.package-dialog::backdrop { background: rgb(16 17 21 / 58%); }

.package-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--rule);
}

.package-dialog h2 { margin: 0.25rem 0 0; font-size: 1.8rem; }

.package-dialog-header button {
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--display);
  font-size: 1.8rem;
}

.package-dialog pre {
  max-height: 30rem;
  margin: 0;
  padding: 1.5rem;
  overflow: auto;
  background: #f1f1ed;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.package-dialog > p {
  margin: 0;
  padding: 0.8rem 1.4rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.62rem;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes voice-wave { to { transform: scaleY(0.45); opacity: 0.55; } }
@keyframes node-in { from { opacity: 0; transform: translateY(0.5rem); } }

@media (max-width: 1040px) {
  .trial-page {
    display: block;
    min-height: 100svh;
    overflow: visible;
  }

  .trial-header { height: 4.75rem; }

  .trial-workspace { display: block; }

  .conversation-panel {
    min-height: auto;
    padding: 1.5rem;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    overflow: visible;
  }

  .conversation-intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
  }

  .conversation-intro h1 { max-width: 31rem; }
  .conversation-intro > p { grid-column: 1 / -1; }
  .voice-console { min-height: 17rem; }
  .listening-block { display: none; }

  .map-panel { min-height: 38rem; grid-template-rows: 3.75rem 3.5rem 30rem 3.1rem; }
  .graph-track { justify-content: flex-start; }
  .map-viewport { padding: 2rem 1.5rem; }

  .trial-progress {
    position: sticky;
    z-index: 10;
    bottom: 0;
    min-height: 5.5rem;
    padding: 0 1.5rem;
    background: var(--paper);
  }

  .handoff-panel { width: min(44rem, 86vw); }
}

@media (max-width: 680px) {
  .trial-header { height: 4rem; margin: 0 1.1rem; }
  .trial-header-note { display: none; }
  .trial-brand img { width: 1.6rem; height: 1.6rem; }
  .trial-brand span { font-size: 0.9rem; }

  .conversation-panel { gap: 0.7rem; padding: 1.4rem 1.1rem; }
  .conversation-intro { display: block; }
  .conversation-intro h1 { max-width: 19rem; font-size: 2.5rem; }
  .conversation-intro > p { max-width: 22rem; font-size: 0.87rem; }

  .trial-summary { min-height: 4.5rem; }
  .trial-summary > p { max-width: 15rem; }
  .voice-console { min-height: 18rem; grid-template-rows: 4.25rem 14rem; }
  .interview-button { min-height: 3.6rem; }

  .map-panel { min-height: 38rem; grid-template-rows: auto 3.5rem 29rem 3rem; }
  .map-tabs-row {
    display: block;
    padding: 0;
  }

  .map-tabs { width: 100%; height: 3.6rem; }
  .map-tabs button { min-width: 0; flex: 1; padding: 0 0.3rem; font-size: 0.72rem; }
  .map-status { padding: 0.75rem 1.1rem; border-top: 1px solid var(--rule-soft); }
  .map-heading-row { padding: 0 1.1rem; }
  .map-heading-row .section-label { display: none; }
  .map-viewport { padding: 1.5rem 1.1rem; }
  .map-empty { width: 100%; }
  .graph-node { width: 10.5rem; min-height: 11rem; }
  .graph-connector { width: 2.5rem; }
  .map-legend { gap: 0.8rem; padding: 0 1.1rem; overflow-x: auto; white-space: nowrap; }

  .trial-progress {
    grid-template-columns: 1fr auto 1fr auto 1fr;
    gap: 0.45rem;
    min-height: 5rem;
    padding: 0 0.75rem;
  }

  .trial-progress > div { justify-content: center; gap: 0; }
  .trial-progress > div > span { width: 1.55rem; height: 1.55rem; }
  .trial-progress p { display: none; }
  .trial-progress > svg { width: 1rem; height: 1rem; }

  .handoff-panel { width: 100vw; }
  .handoff-scroll { padding: 4rem 1.15rem 1.4rem; }
  .handoff-panel h2 { max-width: 20rem; font-size: 2.65rem; }
  .handoff-split { display: block; }
  .handoff-split > div + div { padding: 1rem 0 0; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
