/* ZODEYX Technology Decision Study — styles.
   Dark by default (direction: dark, scientific, calm, precise). Light kept only as an explicit theme. */
@property --reach { syntax: '<percentage>'; inherits: true; initial-value: 0%; }

:root {
  --bg: #0F1519;
  --bg-2: #151D22;
  --bg-3: #1B252B;
  --line: #2B373E;
  --edge: #5E6C72;
  --ink: #E7E5DE;
  --ink-2: #9AA5A8;
  --ink-3: #6E7B80;
  --ice: #9CC5CB;
  --brass: #CDB27B;
  --pain: #D98F96;
  --dot: rgba(231, 229, 222, .2);
  --scrim: rgba(15, 21, 25, .93);
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="light"] {
  --bg: #ECEEEA; --bg-2: #E1E5E0; --bg-3: #D6DCD6; --line: #C4CBC6; --edge: #7E8B90;
  --ink: #172025; --ink-2: #56636A; --ink-3: #7A868B; --ice: #2C6B75; --brass: #86682B; --pain: #A5424F;
  --dot: rgba(23, 32, 37, .22); --scrim: rgba(236, 238, 234, .92);
  color-scheme: light;
}
html { height: 100%; }
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 400 1.0625rem/1.55 var(--sans); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ice); outline-offset: 3px; border-radius: 3px; }
[hidden] { display: none !important; }

.app { position: relative; height: 100%; display: grid; grid-template-rows: auto 1fr; overflow: hidden; }

/* The field: almost empty at first, it extends as the study learns about the person. */
.field {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1.4px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(circle at 42% 52%, #000 0%, transparent var(--reach));
          mask-image: radial-gradient(circle at 42% 52%, #000 0%, transparent var(--reach));
  transition: --reach 1.8s cubic-bezier(.2,.7,.2,1);
}
body[data-scene="entry"]             { --reach: 9%; }
body[data-scene="story"]             { --reach: 24%; }
body[data-scene="building"]          { --reach: 42%; }
body[data-scene="graph"]             { --reach: 78%; }
body[data-scene="pain"]              { --reach: 78%; }
body[data-scene="current_method"]    { --reach: 88%; }
body[data-scene="cost"]              { --reach: 96%; }
body[data-scene="criteria_survival"] { --reach: 104%; }
body[data-scene="forced_choice"]     { --reach: 112%; }
body[data-scene="interim_end"]       { --reach: 130%; }

/* Optional video layers (Higgsfield). Invisible until playable. */
.media { position: absolute; inset: 0; pointer-events: none; z-index: 0; opacity: 0; transition: opacity 1.4s ease; overflow: hidden; }
.media img, .media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media.on.has-poster { opacity: .35; }
.media.on.playing { opacity: .45; }
.media video { opacity: 0; transition: opacity 1.2s ease; }
.media.playing video { opacity: 1; }
/* Behind the live graph the texture recedes, so it never competes with the participant's own map. */
body[data-scene="graph"] .media[data-asset="graph"].on.has-poster,
body[data-scene="graph"] .media[data-asset="graph"].on.playing { opacity: .16; }
/* While the participant writes, the entry atmosphere steps back. */
body[data-scene="story"] .media[data-asset="entry"].on.has-poster,
body[data-scene="story"] .media[data-asset="entry"].on.playing { opacity: .2; }
/* On phones the text covers the whole width, so the background stays quieter. */
@media (max-width: 760px) {
  body[data-scene="entry"] .media[data-asset="entry"].on.has-poster,
  body[data-scene="entry"] .media[data-asset="entry"].on.playing { opacity: .3; }
}

.bar {
  position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px clamp(20px, 5vw, 56px) 8px;
}
.mark { font-size: .9375rem; letter-spacing: .02em; color: var(--ink-2); }
.mark b { font-weight: 600; letter-spacing: .16em; color: var(--ink); margin-right: .35em; }
.bar-tools { display: flex; align-items: center; gap: 12px; }
.dbg-badge { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--brass); border: 1px solid var(--brass); border-radius: 999px; padding: 2px 8px; }
.textbtn {
  background: none; border: 0; padding: 8px 2px; cursor: pointer; color: var(--ink-2);
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px;
}
.textbtn:hover { color: var(--ink); text-decoration-color: var(--ink-2); }

main { position: relative; z-index: 1; min-height: 0; }
.scene {
  position: absolute; inset: 0; overflow-y: auto; opacity: 0; visibility: hidden;
  transition: opacity .45s ease, visibility 0s linear .45s;
}
.scene.on { opacity: 1; visibility: visible; transition: opacity .45s ease .1s, visibility 0s; }

.col {
  min-height: 100%; display: flex; flex-direction: column; justify-content: center;
  width: min(36rem, 100%); margin-left: clamp(20px, 12vw, 200px); margin-right: 20px;
  padding: 24px 0 48px;
}
/* Top-anchored on purpose: content that grows (a question appearing) must never shift what's above it. */
.wide {
  width: min(64rem, calc(100% - 40px)); margin: 0 auto; padding: clamp(16px, 7vh, 72px) 0 40px;
  min-height: 100%; display: flex; flex-direction: column; justify-content: flex-start;
}
@media (max-width: 640px) {
  .col { margin-left: 16px; margin-right: 16px; width: auto; justify-content: flex-start; padding-top: 6vh; }
  .wide { width: calc(100% - 32px); justify-content: flex-start; padding-top: 12px; }
}

h1, h2 { font-family: var(--serif); font-weight: 400; margin: 0; letter-spacing: -.012em; }
h1 { font-size: clamp(2.5rem, 1.3rem + 4.2vw, 4.4rem); line-height: 1.02; font-variation-settings: "opsz" 72; }
h2 { font-size: clamp(1.7rem, 1.15rem + 2.1vw, 2.75rem); line-height: 1.12; font-variation-settings: "opsz" 60; }
h1:focus, h2:focus { outline: none; }
.wide h2 { max-width: 44rem; }
.lead { font-family: var(--serif); font-style: italic; font-size: 1.25rem; line-height: 1.45; color: var(--ink-2); margin: 0 0 14px; }
.lead-after { margin: 18px 0 0; font-size: clamp(1.25rem, 1rem + 1vw, 1.6rem); color: var(--ink); }
.lead em { color: var(--ink); }
.body { max-width: 33rem; margin: 14px 0 0; color: var(--ink-2); }
.body strong { color: var(--ink); font-weight: 500; }
.small { font-size: .9375rem; color: var(--ink-2); line-height: 1.5; }
.hint { margin: 10px 0 0; }

.pill {
  appearance: none; border: 0; cursor: pointer; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-weight: 500;
  padding: 13px 26px; min-height: 48px; transition: transform .15s ease, opacity .2s;
}
.pill:hover { transform: translateY(-1px); }
.pill:disabled { opacity: .3; cursor: not-allowed; transform: none; }
.ghost {
  appearance: none; cursor: pointer; border-radius: 999px; background: transparent;
  border: 1px solid var(--line); padding: 12px 20px; min-height: 48px; color: var(--ink);
}
.ghost:hover { border-color: var(--ink-2); }
.ghost:disabled { opacity: .35; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-top: 30px; }
.row .push { margin-left: auto; }

/* Tokens: the manipulable objects of scenes 4–6 */
.tok {
  appearance: none; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink);
  border-radius: 999px; padding: 9px 16px; min-height: 42px;
  font: 500 .8125rem/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase;
  transition: opacity .25s, border-color .2s, background .2s, transform .2s;
}
.tok:hover { border-color: var(--ink-2); }
.tok.tok-quiet { color: var(--ink-2); border-style: dashed; }
.tok.tok-small { min-height: 34px; padding: 6px 12px; font-size: .75rem; cursor: pointer; touch-action: manipulation; }
.tok.dragging { opacity: .25; }
.ghost-drag { box-shadow: 0 10px 30px rgba(0,0,0,.35); cursor: grabbing; opacity: .95; }

/* Entry */
.consent { margin-top: 30px; padding-left: 18px; border-left: 1px solid var(--line); display: grid; gap: 14px; max-width: 32rem; }
.consent p { margin: 0; }
.switch { display: flex; align-items: flex-start; gap: 14px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.switch .track { flex: none; width: 38px; height: 22px; border-radius: 11px; border: 1px solid var(--ink-2); position: relative; margin-top: 2px; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink-2); transition: transform .2s, background .2s; }
.switch[aria-checked="true"] .track { background: var(--ink); border-color: var(--ink); }
.switch[aria-checked="true"] .track::after { transform: translateX(16px); background: var(--bg); }
.switch .t1 { display: block; color: var(--ink); font-weight: 500; }
.switch .t2 { display: block; font-size: .9375rem; color: var(--ink-2); }

/* Story */
.modes { display: flex; gap: 6px; margin: 26px 0 10px; }
.mode {
  appearance: none; background: none; border: 0; cursor: pointer; padding: 8px 14px 8px 0; color: var(--ink-2);
  font-size: .9375rem; border-bottom: 1px solid transparent;
}
.mode[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.mode + .mode { padding-left: 14px; }
.voice-note { margin: 0 0 12px; }
.writing {
  width: 100%; min-height: 9.5em; resize: vertical; background: transparent;
  border: 0; border-left: 1px solid var(--line); padding: 4px 0 4px 18px;
  font-family: var(--serif); font-size: 1.25rem; line-height: 1.55; color: var(--ink);
}
.writing:focus { outline: none; border-left-color: var(--ice); }
.writing::placeholder { color: var(--ink-2); opacity: .7; font-style: italic; }
.mic { display: none; align-items: center; gap: 14px; margin: 0 0 16px 18px; }
.mic.on { display: flex; }
.recdot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.recdot.live { background: var(--pain); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.notice { min-height: 1.5em; margin: 10px 0 0 18px; font-size: .9375rem; color: var(--ink-2); }
.notice.ask { font-family: var(--serif); font-style: italic; font-size: 1.2rem; color: var(--ink); }

/* Building */
.reading p { font-family: var(--serif); font-size: 1.2rem; line-height: 1.6; color: var(--ink-2); margin: 0; }
.reading .sent { transition: color .5s ease, background-color .5s ease; border-radius: 2px; }
.reading .sent.hot { color: var(--ink); background: color-mix(in srgb, var(--ice) 14%, transparent); }
.status { margin-top: 26px; display: flex; align-items: center; gap: 12px; color: var(--ink-2); }
.status .bead { width: 7px; height: 7px; border-radius: 50%; background: var(--ice); animation: pulse 1.2s ease-in-out infinite; }

/* Graph scene */
.gscene { display: grid; grid-template-rows: auto 1fr auto; height: 100%; min-height: 540px; }
.ghead { padding: 10px clamp(20px, 5vw, 56px) 0; max-width: 46rem; }
.ghead h2 { font-size: clamp(1.55rem, 1.1rem + 1.6vw, 2.3rem); }
.ghead p { margin: 10px 0 0; color: var(--ink-2); max-width: 38rem; }
.ghead .hint { font-size: .875rem; margin-top: 6px; }
.gbox { position: relative; min-height: 0; margin: 8px clamp(8px, 3vw, 40px) 0; }
svg.graph { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; overflow: visible; z-index: 1; }
.edge { fill: none; stroke: var(--edge); stroke-width: 1.2; transition: opacity .5s, stroke-dasharray .5s; }
.edge.broken { stroke-dasharray: 3 5; opacity: .35; }
.node { cursor: grab; outline: none; }
.node .hit { fill: transparent; }
.node .s { fill: var(--bg); stroke: var(--tone); stroke-width: 1.5; transition: stroke .3s, fill .3s; }
.node .f { fill: var(--tone); transition: fill .3s; }
.node .halo { fill: none; stroke: var(--ice); stroke-width: 1.5; opacity: 0; transition: opacity .2s; }
.node.sel .halo, .node:focus-visible .halo { opacity: 1; }
.node.linksrc .halo { opacity: 1; stroke-dasharray: 3 3; }
.node.unanchored .s { stroke-dasharray: 2.5 2.5; }
.lbl { font: 500 13px/1 var(--sans); fill: var(--ink); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.cap { font: 400 11px/1 var(--sans); fill: var(--ink-2); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.lift { transition: transform .7s cubic-bezier(.2,.8,.2,1), opacity .4s; }
.mode-pain .node { cursor: pointer; }
.mode-pain .node.pain .s { stroke: var(--pain); }
.mode-pain .node.pain .f { fill: var(--pain); }
.mode-pain .node.pain .lbl { fill: var(--pain); }
.mode-pain.has-pain .node:not(.pain) .lift { opacity: .35; }
.mode-pain.has-pain .edge:not(.broken) { opacity: .3; }
.empty-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; color: var(--ink-2); max-width: 22rem; pointer-events: none; }

.gfoot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px clamp(20px, 5vw, 56px) 18px; position: relative; z-index: 3; }
.gfoot .push { margin-left: auto; }

.panel {
  position: absolute; z-index: 4; right: 0; top: 0; width: min(320px, 100%);
  background: var(--scrim); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: none;
}
.panel.on { display: block; }
.panel label { display: block; font-size: .8125rem; color: var(--ink-2); margin-bottom: 12px; }
.panel input[type=text], .panel select, .panel textarea {
  display: block; width: 100%; margin-top: 5px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font-size: 1rem; color: var(--ink);
}
.panel textarea { resize: vertical; font-family: var(--serif); font-size: 1.0625rem; }
.panel input:focus, .panel select:focus, .panel textarea:focus { outline: none; border-color: var(--ice); }
.panel.pain-panel { border-color: color-mix(in srgb, var(--pain) 45%, var(--line)); }
.quote { font-family: var(--serif); font-style: italic; font-size: 1rem; color: var(--ink-2); margin: 2px 0 14px; line-height: 1.45; }
.quote.warn { font-style: normal; font-family: var(--sans); font-size: .875rem; color: var(--brass); }
.links { margin: 0 0 14px; padding: 0; list-style: none; font-size: .9375rem; }
.links li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px solid var(--line); }
.links li:last-child { border-bottom: 1px solid var(--line); }
.links .x { background: none; border: 0; color: var(--ink-2); cursor: pointer; padding: 6px 8px; font-size: .875rem; }
.links .x:hover { color: var(--pain); }
.panel .acts { display: flex; flex-wrap: wrap; gap: 8px; }
.panel .acts .ghost, .panel .acts .pill { min-height: 40px; padding: 8px 14px; font-size: .9375rem; }
.panel .danger { color: var(--pain); }
.panel h3 { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; margin: 0 0 10px; }
.banner { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 5; background: var(--ink); color: var(--bg); border-radius: 999px; padding: 9px 18px; font-size: .9375rem; display: none; white-space: nowrap; }
.banner.on { display: block; }

@media (min-width: 761px) { .panel.left { right: auto; left: 0; } }
.short { display: none; }
@media (max-width: 760px) {
  .short { display: inline; } .long { display: none; }
  .ghead h2 { font-size: 1.5rem; }
  .ghead p { font-size: .9375rem; margin-top: 6px; }
  .gfoot { flex-wrap: nowrap; gap: 8px; padding-top: 8px; }
  .gfoot .ghost, .gfoot .pill { min-height: 44px; padding: 10px 14px; }
  .gfoot .pill { padding: 10px 18px; }
  .panel { top: auto; bottom: 0; right: 0; left: 0; width: auto; border-radius: 14px 14px 0 0; max-height: 72%; overflow-y: auto; }
  .gbox { margin-left: 4px; margin-right: 4px; }
  .ghead .hint { display: none; }
}

/* Scene 4 — current method */
.pool { display: flex; flex-wrap: wrap; gap: 10px 10px; margin: 26px 0 0; max-width: 56rem; }
.pool .tok[aria-pressed="true"] { opacity: .3; border-style: dotted; }
.trayzone {
  margin-top: 30px; padding: 16px 18px 18px; border: 1px dashed var(--line); border-radius: 18px;
  min-height: 108px; position: relative; transition: border-color .2s, background .2s;
}
.trayzone.over { border-color: var(--ice); background: color-mix(in srgb, var(--ice) 6%, transparent); }
.traylabel { margin: 0 0 10px; font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.tray { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 26px; }
.titem {
  position: relative; display: flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 6px 6px 6px 12px; border: 1px solid var(--ice); border-radius: 999px; background: var(--bg-2);
  font: 500 .8125rem/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.titem.dragging { opacity: .25; }
.titem:not(:last-child)::after { content: "→"; position: absolute; right: -20px; color: var(--edge); letter-spacing: 0; pointer-events: none; }
.tnum { font: 400 .75rem/1 var(--sans); color: var(--ink-2); letter-spacing: 0; }
.tx { appearance: none; border: 0; background: none; color: var(--ink-2); cursor: pointer; width: 32px; height: 32px; border-radius: 50%; font-size: 1.1rem; line-height: 1; }
.tx:hover { color: var(--pain); background: var(--bg-3); }
.other-in { background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 4px 2px; width: 12rem; max-width: 50vw; font: 400 .9375rem/1.2 var(--sans); letter-spacing: 0; text-transform: none; color: var(--ink); }
.other-in:focus { outline: none; border-bottom-color: var(--ice); }
.trayempty { margin: 0; color: var(--ink-3); font-style: italic; font-family: var(--serif); font-size: 1.05rem; }
.suff { margin-top: 26px; }
.suffq { font-family: var(--serif); font-size: 1.5rem; margin: 0 0 10px; }
.words { display: flex; gap: 8px 28px; flex-wrap: wrap; }
.word {
  appearance: none; background: none; border: 0; cursor: pointer; padding: 6px 0;
  font-family: var(--serif); font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem); color: var(--ink-3);
  border-bottom: 1px solid transparent; transition: color .2s, border-color .2s;
}
.word:hover { color: var(--ink-2); }
.word[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ice); }

/* Scene 5 — cost timeline */
.timeline { margin-top: 26px; display: grid; gap: 6px; }
.trow { display: grid; grid-template-columns: 9.5rem 1fr 8.5rem auto; align-items: center; gap: 4px 16px; min-height: 52px; }
.tname { font: 500 .8125rem/1.25 var(--sans); letter-spacing: .1em; text-transform: uppercase; }
.tfrom { display: block; font: 400 .75rem/1.3 var(--sans); letter-spacing: 0; text-transform: none; color: var(--ink-3); margin-top: 2px; }
/* pan-y: a vertical swipe still scrolls the page on phones; a horizontal one sets the duration. */
.track { position: relative; height: 40px; margin: 0 10px; cursor: pointer; touch-action: pan-y; border-radius: 6px; }
.track:focus-visible { outline-offset: 2px; }
.track .rail { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line); }
.track .fill { position: absolute; left: 0; top: calc(50% - 5px); height: 10px; border-radius: 5px; background: color-mix(in srgb, var(--brass) 70%, transparent); transition: width .15s ease; }
.track .knob { position: absolute; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--brass); transition: left .15s ease; }
.trow.unset .knob { border-color: var(--edge); border-style: dashed; }
.trow.dk .fill { background: repeating-linear-gradient(90deg, var(--line) 0 4px, transparent 4px 8px); width: 100% !important; }
.trow.dk .knob { display: none; }
.tval { font-family: var(--serif); font-size: 1.05rem; color: var(--ink); }
.trow.unset .tval, .trow.dk .tval { color: var(--ink-3); font-style: italic; }
.tacts { display: flex; align-items: center; gap: 4px; }
.tdk { font-size: .8125rem; }
.tdk[aria-pressed="true"] { color: var(--ink); }
.tempty { margin: 0; }
.addsteps { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.addsteps .small { margin-right: 4px; }
.total { margin: 16px 0 0; min-height: 1.5em; color: var(--ink); }
.madlib { margin: 22px 0 0; display: grid; gap: 10px; font-family: var(--serif); font-size: 1.25rem; line-height: 1.5; color: var(--ink-2); max-width: 44rem; }
.madlib .ml { display: block; }
.madlib .kinds { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 1rem; }
.ink-tok {
  appearance: none; background: none; border: 0; border-bottom: 1px solid var(--brass); padding: 0 2px; cursor: pointer;
  font: inherit; color: var(--ink); min-height: 32px;
}
.ink-tok.empty { color: var(--brass); font-style: italic; border-bottom-style: dashed; }
.ink-tok:hover { color: var(--brass); }
.menu {
  position: fixed; z-index: 60; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.4); display: grid; max-height: 60vh; overflow-y: auto;
}
.menu .opt { appearance: none; text-align: left; background: none; border: 0; border-radius: 8px; padding: 10px 12px; cursor: pointer; color: var(--ink); font-size: 1rem; }
.menu .opt:hover, .menu .opt:focus-visible { background: var(--bg-3); outline: none; }
.menu .opt[aria-selected="true"] { color: var(--brass); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-top: 28px; }
.ccard {
  appearance: none; text-align: left; cursor: pointer; display: grid; gap: 8px; align-content: start;
  min-height: 140px; padding: 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .3s, border-color .2s;
}
.ccard:hover { border-color: var(--ink-2); }
.cname { font: 500 .8125rem/1.2 var(--sans); letter-spacing: .12em; text-transform: uppercase; }
.cdet { font-family: var(--serif); font-size: 1.15rem; color: var(--ink-2); }
.cards.has-pick .ccard:not([aria-pressed="true"]) { opacity: .45; }
.ccard[aria-pressed="true"] { transform: translateY(-10px); border-color: var(--pain); border-style: dashed; }
.ccard[aria-pressed="true"] .cname { text-decoration: line-through; text-decoration-color: var(--pain); }

@media (max-width: 760px) {
  .trow { grid-template-columns: 1fr auto; grid-template-areas: "name acts" "track track" "val val"; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .trow .tname { grid-area: name; } .trow .tacts { grid-area: acts; } .trow .track { grid-area: track; } .trow .tval { grid-area: val; margin-top: -6px; }
  .madlib { font-size: 1.1rem; }
}

/* Scene 6 — criteria survival */
.cscene { display: grid; grid-template-rows: auto 1fr auto; min-height: 100%; padding: 10px clamp(16px, 5vw, 56px) 18px; }
.chead h2 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.75rem); }
.critelim { display: grid; grid-template-rows: 1fr auto auto auto; min-height: 0; }
.ring { position: relative; min-height: 380px; max-height: 620px; width: 100%; max-width: 1040px; margin: 10px auto 0; }
.ring-core { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; border: 1px solid var(--ice); }
.ring .ctok { position: absolute; white-space: nowrap; transform: translate(-50%, -50%); transition: left .6s cubic-bezier(.2,.8,.2,1), top .6s cubic-bezier(.2,.8,.2,1), opacity .3s; }
.ring .ctok.dragging { opacity: .2; }
/* Anchored at the top: the list of removed criteria growing below must not move what's left to tap. */
.ring.cloud { display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 10px; min-height: 300px; padding: 6vh 0 10px; }
.ring.cloud .ring-core { display: none; }
.ring.cloud .ctok { position: static; transform: none; }
.ctok.falling { animation: fall .45s ease-in forwards; pointer-events: none; }
.ctok.void { visibility: hidden; pointer-events: none; }
@keyframes fall { to { opacity: 0; translate: 0 40px; filter: blur(2px); } }
.critleft { margin: 6px 0 0; text-align: center; }
.removed { display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; justify-content: center; gap: 8px; margin-top: 12px; min-height: 84px; }
.tok.gone { color: var(--ink-3); text-decoration: line-through; border-style: dotted; background: transparent; }
.critelim .row { justify-content: center; margin-top: 8px; }
.critrank { display: flex; align-items: center; justify-content: center; padding: 20px 0; }
.podium { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; width: min(28rem, 100%); }
.pitem {
  display: grid; grid-template-columns: 2.4rem 1fr auto; align-items: center; gap: 12px;
  min-height: 64px; padding: 8px 10px 8px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.pitem:first-child { border-color: var(--ice); }
.pitem.dragging { opacity: .25; }
.pnum { font-family: var(--serif); font-size: 2rem; line-height: 1; color: var(--ink-2); }
.pitem:first-child .pnum { color: var(--ice); }
.pname { font: 500 .9375rem/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase; }
.pmove { display: flex; gap: 2px; }
.pm { appearance: none; border: 0; background: none; color: var(--ink-2); width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 1.05rem; }
.pm:hover:not(:disabled) { background: var(--bg-3); color: var(--ink); }
.pm:disabled { opacity: .2; cursor: default; }
.cfoot { margin-top: 10px; }

/* Scene 7 — forced choice: doors */
.doors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 28px; }
.door {
  appearance: none; cursor: pointer; text-align: left; color: var(--ink);
  display: grid; grid-template-rows: auto auto auto 1fr; gap: 10px; align-content: start;
  min-height: 300px; padding: 22px 18px; border-radius: 120px 120px 14px 14px;
  border: 1px solid var(--line); background: linear-gradient(to bottom, var(--bg-2), var(--bg));
  transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .35s, border-color .25s;
}
.door:hover { border-color: var(--ink-2); }
.dname { font-family: var(--serif); font-size: 1.35rem; line-height: 1.2; padding-top: 44px; }
.dprice { font: 500 1.5rem/1 var(--sans); letter-spacing: .02em; }
.dtime { font-size: .9375rem; color: var(--ink-2); }
.dtrade { align-self: end; font-family: var(--serif); font-style: italic; font-size: 1rem; color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 12px; }
.doors.has-pick .door:not([aria-pressed="true"]) { opacity: .45; transform: scale(.97); }
.door[aria-pressed="true"] { border-color: var(--ice); transform: translateY(-6px); }
@media (max-width: 860px) {
  .doors { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .doors { grid-template-columns: 1fr; gap: 10px; }
  .door { min-height: 0; border-radius: 14px; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; padding: 16px; gap: 6px 12px; }
  .dname { padding-top: 0; font-size: 1.2rem; grid-column: 1; }
  .dprice { grid-column: 2; grid-row: 1; font-size: 1.2rem; }
  .dtime { grid-column: 1 / -1; }
  .dtrade { grid-column: 1 / -1; padding-top: 8px; }
  .door[aria-pressed="true"] { transform: none; }
  .doors.has-pick .door:not([aria-pressed="true"]) { transform: none; }
}

/* End */
.facts { margin: 30px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 12px 22px; max-width: 40rem; }
.facts dt { color: var(--ink-2); font-size: .9375rem; }
.facts dd { margin: 0; }
.endnote { margin: 28px 0 0; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; gap: 2px; } .facts dd { margin-bottom: 12px; } }
.contract { margin: 20px 0 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; max-height: 50vh; overflow: auto; }

/* Language switcher: only on the entry screen (the language is fixed once the study begins). */
.lang { display: none; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
body[data-scene="entry"] .lang { display: inline-flex; }
.lang button { appearance: none; border: 0; background: none; color: var(--ink-2); cursor: pointer; border-radius: 999px; padding: 6px 12px; min-height: 36px; font: 600 .8125rem/1 var(--sans); letter-spacing: .08em; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.lang button:hover:not([aria-pressed="true"]) { color: var(--ink); }

/* End: summary + badge */
.endwrap {
  width: min(78rem, calc(100% - 40px)); margin: 0 auto; padding: clamp(16px, 6vh, 64px) 0 40px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 24px 56px; align-items: start;
}
.endwrap .endrow { grid-column: 1 / -1; margin-top: 8px; }
.badge { margin: 0; }
.badge canvas { display: block; width: 100%; height: auto; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.badge figcaption { margin-top: 10px; }
.badgeacts { margin-top: 16px; }
@media (max-width: 960px) {
  .endwrap { grid-template-columns: 1fr; width: calc(100% - 32px); }
}

.plink { color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.plink:hover { color: var(--ink); }
.endref { margin-top: 10px; color: var(--ink-3); }

/* Optional email at the end */
.contact { margin-top: 28px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); display: grid; gap: 10px; }
.contact h3 { font-family: var(--serif); font-weight: 400; font-size: 1.4rem; margin: 0; }
.contact p { margin: 0; }
.contact .clabel { font-size: .8125rem; color: var(--ink-2); margin-top: 4px; }
.contact input[type=email] { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; font-size: 1rem; color: var(--ink); }
.contact input[type=email]:focus { outline: none; border-color: var(--ice); }
.contact .check { display: flex; gap: 10px; align-items: flex-start; font-size: .9375rem; color: var(--ink); cursor: pointer; }
.contact .check input { margin-top: 4px; accent-color: var(--ice); width: 18px; height: 18px; }
.contact .row { margin-top: 6px; }
.cdone { font-family: var(--serif); font-size: 1.2rem; color: var(--ink); }

/* Research log (debug only) */
.log {
  position: absolute; z-index: 30; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--bg-2); border-left: 1px solid var(--line); display: none; grid-template-rows: auto 1fr;
}
.log.on { display: grid; }
.log header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.log header p { margin: 0; font-size: .8125rem; color: var(--ink-2); }
.log pre { margin: 0; overflow: auto; padding: 16px 20px 40px; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink); white-space: pre-wrap; word-break: break-word; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .field, .scene, .scene.on, .lift, .edge, .pill, .ring .ctok, .door, .ccard, .track .fill, .track .knob, .media { transition: none !important; }
  .recdot.live, .status .bead { animation: none; }
  .ctok.falling { animation: none; opacity: 0; }
}
