/* The interactive demo on Research. Runs on v3's tokens, so Light, Mono and Dark carry through.
   One screen, read left to right: set it up (who, where, about what, your goal), the scene with what you say under it,
   and what happened (the verdict, then what went through their head). */
.dm-wrap { width: 100%; max-width: 1480px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); box-sizing: border-box; }
@media (min-width: 760px) { .dm-wrap { padding-inline: 24px; } }
.dm-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dm-small { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.dm-h { margin: 0 0 12px; font-size: 12.5px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* ---- the title: short, so the demo starts high on the page */
.dm-top { padding-block: clamp(20px, 3vw, 36px) clamp(14px, 2vw, 22px); }
.dm-top .v3-crumbs { margin-bottom: 12px; }
.dm-title { display: grid; gap: 10px 48px; align-items: end; }
@media (min-width: 1100px) { .dm-title { grid-template-columns: auto minmax(0, 46ch); } }
.dm-h1 { font-size: clamp(32px, 3.6vw, 54px) !important; line-height: 1.02; margin: 0; }
.dm-dek { margin: 0; font-size: clamp(16px, 1.25vw, 18px); line-height: 1.5; color: var(--muted); max-width: 52ch; }

/* ---- the screen: three columns on wide screens, each scrolling on its own if it must */
.dm-app { padding-bottom: clamp(40px, 6vw, 80px); scroll-margin-top: 76px; }
.dm-shell { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "setup" "center" "result"; }
.dm-setup { grid-area: setup; } .dm-center { grid-area: center; } .dm-result { grid-area: result; }
.dm-col { min-width: 0; min-height: 0; }
.dm-col__h { margin: 2px 2px 10px; font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
@media (min-width: 760px) and (max-width: 1099px) {
  .dm-shell { grid-template-columns: 270px minmax(0, 1fr); grid-template-areas: "setup center" "setup result"; align-items: start; }
  .dm-setup { position: sticky; top: 80px; max-height: calc(100svh - 96px); overflow: auto; }
}
@media (min-width: 1100px) {
  .dm-shell { grid-template-columns: 290px minmax(0, 1fr) 350px; grid-template-areas: "setup center result";
    height: clamp(600px, calc(100svh - 236px), 900px); }   /* the whole screen, Send included, in view on arrival */
  .dm-setup, .dm-result { overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .dm-center { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; }
  .dm-result { display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
  .dm-inside { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
  .dm-rpanel { overflow: auto; min-height: 0; scrollbar-width: thin; }
}
.dm-center { display: grid; gap: 12px; align-content: start; }

/* ---- set it up: four numbered steps, one open at a time, each showing what is chosen */
.dm-step { border: 1px solid var(--line); border-radius: 14px; background: var(--card); margin-bottom: 8px; }
.dm-step > summary { list-style: none; display: grid; grid-template-columns: 26px minmax(0, 1fr) 14px; gap: 10px; align-items: center; padding: 12px 14px; cursor: pointer; border-radius: 14px; }
.dm-step > summary::-webkit-details-marker { display: none; }
.dm-step > summary:focus-visible { outline: 2px solid var(--thread); outline-offset: 2px; }
.dm-step > summary i, .dm-step__h i { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-style: normal; font-size: 13px; font-weight: 800;
  background: color-mix(in srgb, var(--type) 9%, transparent); color: var(--type); }
.dm-step[open] > summary i { background: var(--type); color: var(--ground); }
.dm-step__t { display: grid; min-width: 0; }
.dm-step__t b { font-size: 15.5px; line-height: 1.25; }
.dm-step__t em { font-style: normal; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-chev { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform 200ms var(--ease); }
.dm-step[open] .dm-chev { transform: rotate(180deg); }
.dm-step__body { display: grid; gap: 12px; padding: 0 14px 14px; }
.dm-blurb { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.dm-claim { margin: 0; font-size: 15px; line-height: 1.45; font-weight: 650; }

.dm-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.dm-choice { min-height: 34px; padding: 6px 11px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--type);
  font: 650 13.5px/1.2 var(--f); text-align: left; cursor: pointer; transition: background-color 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease); }
.dm-choice:hover { border-color: var(--type); }
.dm-setup .dm-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dm-setup .dm-choice { min-height: 40px; }
.dm-choice[aria-pressed="true"] { background: var(--type); color: var(--ground); border-color: var(--type); }
.dm-choice:focus-visible { outline: 2px solid var(--thread); outline-offset: 2px; }
@media (pointer: coarse) { .dm-choice { min-height: 44px; } }

.dm-field { display: grid; gap: 4px; min-width: 0; }
.dm-field label, .dm-field > span { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; font-weight: 700; }
.dm-field output { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); }
.dm-field select, .dm-field--inline select { min-height: 38px; padding: 0 10px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--ground); color: var(--type); font: 500 14.5px/1 var(--f); }
.dm-field--inline { display: grid; gap: 6px; font-size: 13.5px; font-weight: 700; }
.dm-range input { width: 100%; accent-color: var(--thread); margin: 2px 0; }
.dm-ends { display: flex; justify-content: space-between; margin: -2px 0 0; font-size: 12px; color: var(--muted); }
.dm-fields { display: grid; gap: 12px 18px; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }
.dm-setup .dm-fields { grid-template-columns: minmax(0, 1fr); }
.dm-group { border-top: 1px solid var(--line); padding-top: 10px; }
.dm-group > summary { cursor: pointer; font-size: 13.5px; font-weight: 700; margin-bottom: 0; }
.dm-group[open] > summary { margin-bottom: 12px; }
.dm-group summary:focus-visible, .dm-why summary:focus-visible, .dm-log summary:focus-visible, .dm-send__more summary:focus-visible { outline: 2px solid var(--thread); outline-offset: 2px; border-radius: 4px; }
.dm-sub { margin: 14px 0 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.dm-pairs { display: grid; gap: 10px; }
.dm-pair { margin: 0; padding: 8px 10px 10px; border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 8px; min-width: 0; }
.dm-pair legend { padding: 0 4px; font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.dm-goals { margin: 0; padding: 0; border: 0; display: grid; gap: 8px; }
.dm-goal { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.dm-goal:has(input:checked) { border-color: var(--type); box-shadow: inset 0 0 0 1px var(--type); }
.dm-goal input { accent-color: var(--thread); margin-top: 2px; width: 17px; height: 17px; }
.dm-goal b { display: block; font-size: 14.5px; }
.dm-goal span span { display: block; font-size: 13px; line-height: 1.4; color: var(--muted); }

/* ---- the stage */
.dm-stage { position: relative; aspect-ratio: 1 / 1; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); min-height: 0;
  background: radial-gradient(120% 90% at 50% 18%, var(--card) 0%, var(--band) 70%); outline: none; touch-action: pan-y; }
@media (min-width: 760px) { .dm-stage { aspect-ratio: 16 / 11; } }
@media (min-width: 1100px) { .dm-stage { aspect-ratio: auto; height: 100%; } }
.dm-stage:focus-visible { box-shadow: 0 0 0 2px var(--ground), 0 0 0 4px var(--thread); }
.dm-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
.dm-canvas:active { cursor: grabbing; }
.dm-fallback { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 12px; padding: 24px; text-align: center; }
.dm-fallback[hidden] { display: none; }
.dm-fallback svg { width: min(360px, 80%); }
.dm-fallback p { margin: 0; max-width: 42ch; font-size: 14.5px; color: var(--muted); }
.dm-fb__ring { fill: none; stroke: var(--thread); stroke-width: 4; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 200px 150px; transition: stroke-dasharray 400ms var(--ease); }
.dm-fb__head, .dm-fb__body { fill: var(--thread); }

.dm-bubble { position: absolute; left: 0; top: 0; z-index: 2; max-width: min(300px, 62%); padding: 10px 14px 12px; border-radius: 16px; pointer-events: none;
  box-shadow: 0 12px 30px -16px rgba(0, 0, 0, 0.45); transition: opacity 400ms var(--ease); }
.dm-bubble[hidden] { display: none; }
.dm-bubble.dm-out { opacity: 0; }
.dm-bubble p { margin: 2px 0 0; font-size: 16.5px; line-height: 1.38; font-weight: 600; text-wrap: pretty; }
.dm-bubble__kind { display: block; font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.7; }
.dm-bubble--thought { background: color-mix(in srgb, var(--card) 94%, transparent); color: var(--type); border: 1.5px dashed color-mix(in srgb, var(--thread) 55%, var(--line)); }
.dm-bubble--thought p { font-style: italic; font-weight: 500; }
.dm-bubble--speech { background: var(--type); color: var(--ground); }
.dm-bubble--quiet { background: color-mix(in srgb, var(--card) 90%, transparent); color: var(--muted); border: 1.5px solid var(--line); }
@media (prefers-reduced-motion: reduce) { .dm-bubble { transition: none; } }

.dm-hud { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.dm-hud > * { pointer-events: auto; }
.dm-clock { margin: 0; padding: 7px 12px; border-radius: 10px; font-size: 14px; background: color-mix(in srgb, var(--card) 86%, transparent);
  border: 1px solid var(--line); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.dm-clock b { font-variant-numeric: tabular-nums; }
.dm-clock span { color: var(--muted); margin-left: 6px; }
.dm-time { display: flex; gap: 6px; align-items: center; }
.dm-tbtn, .dm-speed select { min-height: 34px; padding: 0 11px; border-radius: 10px; border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 86%, transparent);
  color: var(--type); font: 700 13px/1 var(--f); cursor: pointer; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.dm-tbtn:hover, .dm-speed select:hover { border-color: var(--type); }
.dm-tbtn:focus-visible, .dm-speed select:focus-visible { outline: 2px solid var(--thread); outline-offset: 2px; }
@media (pointer: coarse) { .dm-tbtn, .dm-speed select { min-height: 44px; } }
@media (max-width: 420px) { .dm-clock span { display: none; } }

/* ---- step 5: say something, right under the scene */
.dm-send { display: grid; gap: 10px; padding: 14px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.dm-send__top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.dm-step__h { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 15.5px; }
.dm-step__h i { background: var(--type); color: var(--ground); }
.dm-send__box { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: stretch; }
@media (max-width: 520px) { .dm-send__box { grid-template-columns: minmax(0, 1fr); } }
.dm-msg { width: 100%; box-sizing: border-box; resize: vertical; min-height: 64px; font: 400 16px/1.45 var(--f); color: var(--type); background: var(--ground);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.dm-msg:focus-visible { outline: 2px solid var(--thread); outline-offset: 1px; border-color: var(--thread); }
.dm-go { min-width: 132px; justify-content: center; gap: 8px; align-self: stretch; }
.dm-go:disabled { opacity: 0.45; cursor: default; }
/* until the first message is sent, the button says where to start */
@media (prefers-reduced-motion: no-preference) {
  .dm-go[data-hint]:not(:disabled) { animation: dm-hint 2.2s var(--ease) infinite; }
}
@keyframes dm-hint { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--hl) 0%, transparent); } 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--hl) 45%, transparent); } }
.dm-send__more summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--muted); }
.dm-send__more[open] { display: grid; gap: 10px; }
.dm-send__more[open] summary { margin-bottom: 2px; }
.dm-reads { font-size: 13px; }

/* ---- what happened: the verdict first, in words, then the numbers */
.dm-card { padding: 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.dm-result .dm-card + .dm-card { margin-top: 12px; }
/* a fresh verdict and fresh thoughts get a brief wash of the highlighter that fades; never an accent border (Shah: banned) */
.dm-verdict { transition: background-color 900ms var(--ease); }
.dm-verdict[data-fresh] { background: color-mix(in srgb, var(--hl) 16%, var(--card)); transition-duration: 120ms; }
.dm-verdict__head { margin: 0; font-size: 26px; line-height: 1.1; font-weight: 850; letter-spacing: -0.015em; }
.dm-verdict__sub { margin: 6px 0 12px; font-size: 14.5px; line-height: 1.45; color: var(--muted); }
.dm-verdict__sub:empty { display: none; }
.dm-readout { height: 40px; }
.dm-readout span { padding: 0 8px; font-size: 12px; }
.dm-nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 10px 0 0; }
.dm-nums div { display: grid; gap: 1px; }
.dm-nums dt { font-size: 12px; color: var(--muted); }
.dm-nums dd { margin: 0; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.dm-obj { margin: 10px 0 0; font-size: 13.5px; line-height: 1.45; }
.dm-obj:empty { display: none; }
.dm-obj span { color: var(--muted); }
.dm-why { margin-top: 8px; }
.dm-why summary { cursor: pointer; font-size: 13.5px; font-weight: 700; }
.dm-why > div { display: grid; gap: 8px; margin-top: 8px; }
.dm-terms { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 13.5px; }
.dm-terms li { display: flex; justify-content: space-between; gap: 10px; }
.dm-terms b { font-variant-numeric: tabular-nums; }
.dm-terms__sum { border-top: 1px solid var(--line); padding-top: 4px; font-weight: 700; }

/* ---- inside their head: three views of the same mind */
.dm-inside { padding: 0; overflow: hidden; }
.dm-rtabs { display: flex; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.dm-rtabs [role="tab"] { appearance: none; border: 0; background: none; color: var(--muted); font: 750 13px/1 var(--f); padding: 11px 8px 12px; cursor: pointer; flex: 1 1 auto;
  border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.dm-rtabs [role="tab"][aria-selected="true"] { color: var(--type); border-bottom-color: var(--type); }
.dm-rtabs [role="tab"]:focus-visible { outline: 2px solid var(--thread); outline-offset: -2px; border-radius: 6px; }
.dm-rpanel { padding: 12px 14px 14px; }
.dm-rpanel[hidden] { display: none; }
@media (max-width: 1099px) { .dm-rpanel { max-height: 520px; overflow: auto; } }

.dm-meters { display: grid; gap: 9px; }
.dm-meter p { display: flex; justify-content: space-between; margin: 0 0 4px; font-size: 13.5px; }
.dm-meter b { font-variant-numeric: tabular-nums; font-weight: 700; }
.dm-bar { position: relative; height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--type) 10%, transparent); overflow: visible; }
.dm-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--thread); transition: width 300ms var(--ease); }
.dm-bar u { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--type); border-radius: 2px; text-decoration: none; transition: left 300ms var(--ease); }
.dm-bar--gate i { background: var(--type); }
.dm-keys { margin-top: 14px; display: grid; gap: 6px; }
.dm-stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.dm-stack span { min-width: 0; transition: flex-grow 400ms var(--ease); }
.dm-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; font-size: 13px; }
.dm-legend li { display: flex; align-items: center; gap: 6px; }
.dm-legend i { width: 10px; height: 10px; border-radius: 3px; border: 1px solid var(--line); flex: none; }
.dm-legend b { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; }
.dm-stack__demographics { background: color-mix(in srgb, var(--type) 18%, var(--card)); }
.dm-stack__psychographics { background: color-mix(in srgb, var(--type) 40%, var(--card)); }
.dm-stack__mindstate { background: var(--thread); }
.dm-stack__environment { background: color-mix(in srgb, var(--type) 8%, var(--card)); }
.dm-belief { margin-top: 10px; }

.dm-modes { display: grid; gap: 5px; }
.dm-mode { display: grid; grid-template-columns: 70px 76px minmax(0, 1fr) 42px; gap: 8px; align-items: center; font-size: 13px; }
.dm-mode__n { font-weight: 700; }
.dm-mode__d { color: var(--muted); }
.dm-mode--resonance .dm-mode__d { color: var(--thread); font-weight: 700; }
.dm-mode--friction .dm-mode__d { color: var(--type); font-weight: 700; }
.dm-mode__bar { position: relative; height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--type) 10%, transparent); }
.dm-mode__bar::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--line); }
.dm-mode__bar i { position: absolute; top: 0; bottom: 0; background: var(--thread); border-radius: 99px; transition: width 300ms var(--ease); }
.dm-mode__bar i.neg { background: var(--muted); }
.dm-mode b { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.dm-modes + .dm-small { margin-top: 10px; }

/* ---- the log: newest first; the newest line is marked for a moment */
.dm-log__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dm-log__empty { margin-top: 2px; }
.dm-log__list:not(:empty) + .dm-log__empty { display: none; }
.dm-log__item { padding: 9px 11px; border-radius: 12px; background: var(--ground); border: 1px solid var(--line); transition: background-color 900ms var(--ease); }
.dm-log__item[data-fresh] { background: color-mix(in srgb, var(--hl) 18%, var(--ground)); transition-duration: 120ms; }
.dm-log__item--message { background: transparent; border-style: dashed; }
.dm-log__item--quiet .dm-log__text { color: var(--muted); }
.dm-log__meta { display: flex; gap: 10px; margin: 0 0 3px; font-size: 11.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.dm-log__meta span:first-child { font-variant-numeric: tabular-nums; letter-spacing: 0; }
.dm-log__text { margin: 0; font-size: 15px; line-height: 1.45; }
.dm-log__item--thought .dm-log__text { font-style: italic; }
.dm-log details { margin-top: 6px; }
.dm-log summary { cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.dm-trace { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; line-height: 1.45; }
.dm-trace b { font-weight: 700; }
.dm-trace code { display: block; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); overflow-wrap: anywhere; }

/* ---- how it works */
.dm-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px 32px; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); counter-reset: dm; }
.dm-steps li { counter-increment: dm; padding-top: 14px; border-top: 2px solid var(--type); display: grid; gap: 6px; }
.dm-steps li::before { content: counter(dm); font-size: 13px; font-weight: 800; color: var(--muted); }
.dm-steps b { font-size: 20px; line-height: 1.2; font-weight: 850; letter-spacing: -0.01em; }
.dm-steps span { font-size: 16px; line-height: 1.5; color: var(--muted); }
.dm-note { margin-top: 28px; }
@media (prefers-reduced-motion: reduce) { .dm-verdict, .dm-log__item, .dm-chev { transition: none; } }
