/* Research app: light lab theme. Warm paper, ink text, one deep-blue accent for data and activity.
   Green = leans bullish, red = leans bearish, amber = mixed or error. State is always also given in text and shape. */
.research-app {
  --bg: #f5f3ee; --bg-2: #efece5; --surface: #ffffff; --surface-2: #faf8f4; --line: #e6e1d7; --line-2: #d6d0c4;
  --text: #1c1e24; --muted: #5a5e69; --dim: #666a74;
  --accent: #2f4fd6; --accent-hi: #2140b8; --accent-soft: #e8ecfb; --accent-mid: #9aabef;
  --good: #1d8a5a; --good-soft: #e3f3ea; --bad: #c63d2f; --bad-soft: #fbe9e6; --amber: #b7791f; --amber-text: #8a5a0e; --amber-soft: #fbf0dc;
  --off: #c9c3b6; --todo: #ece8e0;
  --ease: cubic-bezier(.23,1,.32,1); --ease-io: cubic-bezier(.77,0,.175,1);
  --mono: 'SF Mono','SFMono-Regular',ui-monospace,Menlo,Consolas,monospace;
  --panel-bg: var(--surface);
  --panel-shadow: 0 0 0 1px #e3ded3, 0 1px 2px #1c1e240a, 0 14px 34px -18px #1c1e2433;
  --up: var(--good); --down: var(--bad); --ink: var(--text); --paper: var(--surface); --blue: var(--accent); --navy: var(--text);
  background: var(--bg); color: var(--text); font-family: 'Avenir Next',system-ui,sans-serif; color-scheme: light;
}
.research-app ::selection {background: #cdd6f8; color: var(--text);}
.research-app a {color: var(--accent); overflow-wrap: anywhere;}

/* Shell */
.research-app .topbar {background: var(--surface); color: var(--text); height: auto; padding: 14px 32px; border-bottom: 1px solid var(--line); gap: 24px;}
.brand-mark {position: relative; width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--accent); box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px #c9d2f5;}
.research-app .brand,.research-app .legacy-link {color: var(--text);}
.brand-light {font-weight: 400; color: var(--muted);}
.research-app .research-main {max-width: 1480px; padding: 0 32px;}
.research-nav {position: relative; border: 0; margin-left: auto; max-width: 100%;}
.research-nav button {position: relative; font-size: 13px; min-height: 44px; color: var(--muted);}
@media (hover: hover) and (pointer: fine) {.research-nav button:hover {color: var(--text);}}
.research-nav button[aria-current] {box-shadow: none; color: var(--text);}
#nav-indicator {position: absolute; bottom: 0; left: 0; height: 2px; background: var(--accent); transition: transform 180ms var(--ease); pointer-events: none;}
#nav-indicator.instant {transition: none;}
.desk-toolbar {display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 30px 0 10px;}
.desk-toolbar h1 {font-size: 30px; letter-spacing: -.03em; font-weight: 600; margin: 0; color: var(--text);}
.desk-sub {font-size: 14px; line-height: 1.6; color: var(--muted); margin: 6px 0 0; max-width: 68ch;}
.section-kicker {font-size: 12px; color: var(--muted); margin: 0 0 6px; display: block;}
.run-research {white-space: nowrap; min-height: 48px; padding: 0 22px; border-radius: 12px; font-size: 14px; font-weight: 600; color: #fff; border: 0; gap: 10px;
  background: var(--accent); box-shadow: inset 0 1px 0 #ffffff33, 0 1px 2px #1c1e2433, 0 8px 18px -10px #2f4fd6aa; transition: transform 140ms var(--ease), filter 160ms ease, opacity 200ms ease;}
@media (hover: hover) and (pointer: fine) {.run-research:hover {filter: brightness(1.08);}}
.run-research:active:not(:disabled) {transform: scale(.97);}
.run-research:disabled {opacity: .78; cursor: progress;}
.run-research .run-label {display: inline-block; transition: filter 200ms ease, opacity 200ms ease;}
.run-research[data-swap] .run-label {filter: blur(2px); opacity: .6;}
.run-research[data-busy] .run-arrow {display: none;}
.run-research .run-dot {display: none; width: 7px; height: 7px; border-radius: 50%; background: #fff;}
.run-research[data-busy] .run-dot {display: inline-block; animation: run-pulse 1.2s ease-in-out infinite;}
@keyframes run-pulse {50% {opacity: .35;}}
.run-box {display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 0;}
.run-estimate {margin: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right;}
.run-steps {font-size: 13px; color: var(--muted); text-align: right;}
.run-steps summary {cursor: pointer; min-height: 24px; color: var(--accent);}
.run-steps ol {list-style: none; margin: 6px 0 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--off); border-radius: 10px; text-align: left; min-width: 300px;}
.run-steps li {display: flex; justify-content: space-between; gap: 16px; padding: 3px 0;}
.run-steps li[data-done] {color: var(--dim); text-decoration: line-through;}
.run-steps li[aria-current] {color: var(--text); font-weight: 600;}
.run-step-time {font-variant-numeric: tabular-nums; white-space: nowrap;}
.run-steps .run-step-total {border-top: 1px solid var(--off); margin-top: 4px; padding-top: 6px; color: var(--text);}
.desk-metadata {display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted);}
.research-app #job-status {margin: 0; padding: 0; min-height: 24px; font-size: 13px; color: var(--muted);}
.research-app .subtle {color: var(--muted);}
.advanced-tools {margin: 2px 0 4px; font-size: 12px;}
.advanced-tools summary,.research-app summary {color: var(--muted); cursor: pointer;}
.advanced-tools summary {min-height: 32px; display: list-item; padding: 8px 0;}
.secondary-nav {display: flex; gap: 8px; flex-wrap: wrap;}
.secondary-nav button,.research-app .text-button {background: none; color: var(--accent); border: 0; min-height: 44px; padding: 8px; font: inherit; font-size: 13px; cursor: pointer; border-radius: 6px;}
@media (hover: hover) and (pointer: fine) {.research-app .text-button:hover {color: var(--accent-hi); background: var(--accent-soft);}}

/* Stage: dark lacquer panel, instrument dials lit from within only where data exists */
.hud {position: relative; margin: 10px 0 0; padding: 18px 22px 16px; border-radius: 12px;
  background: var(--surface); box-shadow: var(--panel-shadow);}
.hud::before {content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: var(--lit, .35); transition: opacity 600ms ease;
  background: linear-gradient(180deg, var(--accent-soft), transparent 90px);}
.hud[data-mode=live],.hud[data-mode=replay] {--lit: 1;}
.hud-head {position: relative; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 0 0 6px;}
.hud-head>* {min-width: 0; max-width: 100%;}
.hud-mode {display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted);}
.hud-mode span {overflow-wrap: anywhere; min-width: 0;}
#execution-label {color: var(--text); font-weight: 600; font-size: 15px;}
.hud[data-mode=live] #execution-label,.hud[data-mode=replay] #execution-label {color: var(--accent);}
#execution-count {font-variant-numeric: tabular-nums;}
.replay-bar {display: flex; align-items: center; gap: 12px; flex-wrap: wrap;}
.ghost-button {display: inline-flex; align-items: center; gap: 9px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 0; color: var(--text); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  background: var(--surface); box-shadow: 0 0 0 1px var(--line-2), 0 1px 2px #1c1e2414; transition: transform 140ms var(--ease), filter 160ms ease, opacity 200ms ease;}
@media (hover: hover) and (pointer: fine) {.ghost-button:hover {filter: brightness(1.15);}}
.ghost-button:active {transform: scale(.97);}
.replay-icon {width: 0; height: 0; border-left: 8px solid var(--accent); border-top: 5px solid transparent; border-bottom: 5px solid transparent;}
#replay-toggle[data-state=playing] .replay-icon {width: 8px; height: 10px; border: 0; border-left: 3px solid var(--accent); border-right: 3px solid var(--accent);}
.replay-clock {font-size: 12px; color: var(--muted); min-width: 13ch; font-variant-numeric: tabular-nums;}
#replay-scrub {width: 220px; min-height: 0; padding: 0; accent-color: var(--accent); background: transparent; border: 0;}

.graph-scroll {position: relative; overflow: auto;}
.graph-scroll:focus-visible {outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 12px;}
#workflow-graph {position: relative; aspect-ratio: 1200 / 590; min-height: 540px; width: min(100%, max(1100px, calc((100vh - 310px) * 2.03))); max-width: 1400px; margin: 0 auto;}
#hud-rings,#graph-edges {position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible;}
#hud-rings circle {fill: none;}
.ring-orbit {display: none;}
#graph-edges>path {fill: none; stroke: #d9d4c9; stroke-width: 1.5; stroke-linecap: round; transition: stroke 300ms ease;}
#graph-edges>path[data-complete=true] {stroke: #a9b4dc;}
#graph-edges>path[data-active=true] {stroke: var(--accent);}
#spark-layer {position: absolute; inset: 0; pointer-events: none;}
.spark {position: absolute; left: 0; top: 0; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px #fff;}
#graph-nodes {position: absolute; inset: 0;}

/* Nodes: a machined dial. Ticks around it are real per-candidate results. */
.workflow-node {position: absolute; translate: -50% calc(var(--orb) / -2); --orb: 16px; width: 136px; display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 0; background: none; border: 0; color: var(--text); cursor: pointer; text-align: center; font-family: inherit; border-radius: 12px;}
.workflow-node.kind-agent {--orb: 96px; width: 158px;}
.workflow-node.kind-core {--orb: 156px; width: 190px;}
.workflow-node:focus-visible {outline: 2px solid var(--accent); outline-offset: 6px;}
.workflow-node:active {transform: none;}
.orb {position: relative; width: var(--orb); height: var(--orb); flex: none; border-radius: 50%; display: grid; place-items: center; transition: transform 160ms var(--ease);}
.kind-agent .orb::before,.kind-core .orb::before {content: ''; position: absolute; inset: 17%; border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 1px 2px #1c1e2412, 0 8px 18px -10px #1c1e2440; transition: box-shadow 300ms ease;}
.kind-core .orb::before {inset: 15%;}
.ticks {position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible;}
.tick {fill: none; stroke: var(--todo); stroke-width: 3.2; stroke-linecap: butt; transition: stroke 220ms ease;}
.kind-core .tick {stroke-width: 1.6;}
.tick[data-s=data],.tick[data-s=done] {stroke: var(--accent);}
.tick[data-s=off] {stroke: var(--off);}
.tick[data-s=err] {stroke: var(--amber);}
.tick[data-s=work] {stroke: var(--accent-mid);}
.core-readout {position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; line-height: 1;}
.core-count {font-size: 22px; font-weight: 600; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums;}
.kind-core .core-count {font-size: 32px;}
.core-unit {font-size: 11px; color: var(--muted); margin-top: 4px;}
.workflow-node[data-status=complete] .core-count,.workflow-node[data-status=available] .core-count {color: var(--text);}
.workflow-node[data-working=true] .orb::before {box-shadow: 0 0 0 1.5px var(--accent), 0 1px 2px #1c1e2412, 0 8px 18px -10px #2f4fd666;}
.kind-rail .orb {background: var(--surface); box-shadow: inset 0 0 0 2px var(--line-2);}
.kind-rail[data-status=complete] .orb,.kind-rail[data-status=available] .orb {background: var(--accent); box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px #c9d2f5;}
.kind-rail[data-working=true] .orb {background: var(--surface); box-shadow: inset 0 0 0 4px var(--accent), 0 0 0 4px var(--accent-soft);}
.kind-rail[data-status=unavailable] .orb {background: var(--surface); box-shadow: inset 0 0 0 2px var(--off);}
.kind-rail[data-status=error] .orb,.kind-rail[data-status=failed] .orb {background: var(--amber); box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--amber-soft);}
@media (hover: hover) and (pointer: fine) {
  .workflow-node:hover .node-title {color: var(--accent-hi);}
  .workflow-node:hover .orb::before {box-shadow: 0 0 0 1px #b9c4ef, 0 1px 2px #1c1e2412, 0 10px 20px -10px #1c1e2455;}
}
.workflow-node:active .orb {transform: scale(.97);}
.node-text {display: flex; flex-direction: column; align-items: center; gap: 1px; width: 100%;}
.node-title {font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--text); transition: color 160ms ease;}
.kind-core .node-title {font-size: 15px;}
.node-state {font-size: 12px; line-height: 1.4; color: var(--muted);}
.node-measure {font-size: 12px; line-height: 1.4; color: var(--dim); overflow-wrap: anywhere; font-variant-numeric: tabular-nums;}
.workflow-node:is([data-status=complete],[data-status=available]) .node-state {display: none;}
.workflow-node[data-working=true] .node-state {color: var(--accent);}
.workflow-node[data-status=error] .node-state,.workflow-node[data-status=failed] .node-state {color: var(--amber-text);}

.graph-legend {position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; font-size: 12px; color: var(--muted); margin: 8px 0 0;}
.lg {display: inline-block; width: 12px; height: 4px; border-radius: 2px; margin: 0 2px 0 8px; vertical-align: middle;}
.lg-data {background: var(--accent);}
.lg-off {background: var(--off);}
.lg-err {background: var(--amber);}
.lg-done {background: var(--accent); border-radius: 50%; width: 8px; height: 8px; vertical-align: 0;}
.lg-bull {background: var(--good);}
.lg-bear {background: var(--bad);}
.lg-mixed {background: var(--amber);}
.briefing-key {display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; font-size: 12px; color: var(--muted); margin: -6px 0 14px;}
.briefing-key .lg:first-child {margin-left: 0;}
.lg-todo {background: var(--todo); box-shadow: 0 0 0 1px var(--line-2);}
.mobile-node-picker {display: none;}

/* Briefing: one row per stock, one column per agent; bars are the agents' recorded readings */
.briefing {margin: 20px 0 0; padding: 22px 24px 8px; border-radius: 12px; background: var(--panel-bg); box-shadow: var(--panel-shadow);}
.briefing-head h2 {font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 4px; color: var(--text);}
#briefing-meta {font-size: 13px; line-height: 1.6; color: var(--muted); margin: 0 0 14px;}
#briefing-list {border-top: 1px solid var(--line-2);}
#briefing-list .sig:last-child {border-bottom: 0;}
.sig-row {display: grid; grid-template-columns: 112px repeat(6, 52px) 104px minmax(0,1fr); align-items: center; column-gap: 10px; padding: 12px 8px 12px 16px;}
.sig-head {padding: 10px 8px 8px 16px; font-size: 11px; color: var(--dim); border-bottom: 1px solid var(--line);}
.sig-col {text-align: center;}
.sig {border-bottom: 1px solid var(--line);}
.sig summary {position: relative; list-style: none; cursor: pointer; border-radius: 8px; transition: background 160ms ease;}
.sig summary::before {content: ''; position: absolute; left: 2px; top: 14px; bottom: 14px; width: 3px; border-radius: 2px; background: var(--edge, var(--off));}
.sig[data-stance=favorable] {--edge: var(--good);}
.sig[data-stance=unfavorable] {--edge: var(--bad);}
.sig[data-stance=mixed] {--edge: var(--amber);}
.sig summary::-webkit-details-marker {display: none;}
@media (hover: hover) and (pointer: fine) {.sig summary:hover {background: var(--surface-2);}}
.sig[open] summary {background: linear-gradient(90deg,color-mix(in srgb,var(--edge,var(--off)) 8%,transparent),transparent 60%);}
.sig summary:focus-visible {outline: 2px solid var(--accent); outline-offset: -2px;}
.sig-name {display: flex; flex-direction: column; gap: 2px; min-width: 0;}
.sig-name strong {font-size: 22px; font-weight: 650; letter-spacing: -.02em; color: var(--text); line-height: 1.1;}
.sig-name small {font-size: 12px; color: var(--muted);}
.sig-company {font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.sig-measured {color: var(--muted); font-size: 14px;}
.sig-group {margin: 0; padding: 18px 8px 8px 16px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line);}
.sig-rest .sig-name strong {font-size: 17px;}
.sig-rest .sig-row {padding-top: 9px; padding-bottom: 9px;}
.sig[data-stance=unfavorable] .sig-name small {color: var(--bad);}
.sig[data-stance=favorable] .sig-name small {color: var(--good);}
.sig[data-stance=mixed] .sig-name small {color: var(--amber-text);}
.sig-cell {position: relative; height: 36px;}
.sig-cell::before {content: ''; position: absolute; left: 12px; right: 12px; top: 50%; height: 1px; background: var(--line-2);}
.sig-cell i {position: absolute; left: calc(50% - 3px); width: 6px; border-radius: 3px; height: calc(var(--m) * 16px + 2px);}
.sig-cell[data-state=up] i {bottom: 50%; background: var(--good); transform-origin: bottom;}
.sig-cell[data-state=down] i {top: 50%; background: var(--bad); transform-origin: top;}
.sig-cell[data-state=flat] i {top: calc(50% - 2px); height: 4px; width: 4px; left: calc(50% - 2px); background: var(--dim);}
.sig-cell[data-state=off] i {display: none;}
.cell-label {display: none;}
.sig-cell[data-state=off]::before {left: 22px; right: 22px; background: repeating-linear-gradient(90deg,var(--off) 0 2px,transparent 2px 4px);}
.sig-score {display: flex; flex-direction: column; gap: 6px; align-items: flex-start;}
.sig-score b {font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums;}
.sig-score i {position: relative; display: block; width: 32px; height: 4px; margin-left: 32px; border-radius: 2px; background: var(--bad); transform-origin: left; transform: scaleX(var(--s));}
.sig[data-stance=favorable] .sig-score i {background: var(--good);}
.sig[data-stance=mixed] .sig-score i {background: var(--amber); box-shadow: none;}
.sig-score::after {content: ''; display: block; width: 64px; height: 1px; margin-top: -8px; background: var(--line-2);}
.sig-headline {font-size: 15px; line-height: 1.45; color: var(--text); text-wrap: pretty;}
.sig-body {padding: 2px 8px 18px 138px;}
.sig[open] .sig-body {transition: opacity 200ms var(--ease), transform 200ms var(--ease);}
@starting-style {.sig[open] .sig-body {opacity: 0; transform: translateY(-4px);}}
.sig-reasons {list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 7px;}
.sig-reasons li {display: grid; grid-template-columns: 10ch minmax(0,1fr); gap: 12px; font-size: 14px; line-height: 1.55;}
.reason-agent {color: var(--text); font-weight: 600;}
.reason-point {color: #34373f; overflow-wrap: anywhere;}
.sig-foot {font-size: 12px; line-height: 1.6; color: var(--dim); margin: 0; max-width: 100ch;}
@media(max-width:900px) {
  .sig-head {display: none;}
  .sig-row {grid-template-columns: repeat(6, minmax(0,1fr)); row-gap: 8px;}
  .sig-name {grid-column: 1 / 5;}
  .sig-score {grid-column: 5 / 7; align-items: flex-end;}
  .sig-cell {grid-row: 2;}
  .sig-cell {height: 58px;}
  .sig-cell::before {top: 20px;}
  .sig-cell[data-state=up] i {bottom: auto; top: calc(20px - var(--m) * 16px - 2px);}
  .sig-cell[data-state=down] i {top: 20px;}
  .sig-cell[data-state=flat] i {top: 18px;}
  .cell-label {display: block; position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; color: var(--dim); text-align: center; overflow-wrap: anywhere; line-height: 1.2;}
  .sig-headline {grid-column: 1 / -1;}
  .sig-body {padding: 0 8px 16px;}
  .sig-reasons li {grid-template-columns: 1fr; gap: 0;}
}

/* Outcome + activity */
.hud-lower {display: grid; grid-template-columns: minmax(0,1.05fr) minmax(0,1fr); gap: 20px; padding: 20px 0 34px;}
.run-outcome,.live-log {padding: 22px 24px; border-radius: 12px; background: var(--panel-bg); box-shadow: var(--panel-shadow);}
.run-outcome h2 {font-size: 26px; letter-spacing: -.025em; line-height: 1.25; margin: 0 0 8px; font-weight: 600; color: var(--text);}
.run-outcome p {font-size: 14px; max-width: 64ch; line-height: 1.7; color: var(--muted); margin: 0;}
#outcome-metrics {display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,150px),1fr)); gap: 10px; margin: 22px 0 14px;}
#outcome-metrics:empty {display: none;}
#outcome-metrics div {min-width: 0; overflow-wrap: anywhere; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);}
#outcome-metrics strong,#outcome-metrics span {display: block;}
#outcome-metrics strong {font-size: 24px; font-weight: 600; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums;}
#outcome-metrics span {font-size: 12px; color: var(--muted); margin-top: 3px;}
.outcome-actions {display: flex; gap: 8px; flex-wrap: wrap; margin-left: -8px;}
.live-log {min-width: 0;}
.log-head {display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px;}
.log-head h2 {font-size: 14px; font-weight: 600; letter-spacing: .02em; color: var(--text); margin: 0;}
#log-count {font: 12px var(--mono); color: var(--dim);}
#live-log {list-style: none; margin: 0; padding: 0; max-height: 330px; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;}
.log-row {display: grid; grid-template-columns: 7.5ch 10ch 6ch minmax(0,1fr); gap: 10px; align-items: baseline; padding: 7px 0 7px 16px; position: relative; border-bottom: 1px solid var(--line); font-size: 12px;}
.log-row::before {content: ''; position: absolute; left: 3px; top: 9px; width: 3px; height: 11px; border-radius: 2px; background: var(--todo);}
.log-row.s-done::before {background: var(--accent);}
.log-row.s-work::before {background: var(--accent-mid);}
.log-row.s-off::before {background: var(--off);}
.log-row.s-err::before {background: var(--amber);}
.log-row time {font-family: var(--mono); color: var(--dim);}
.log-agent {color: var(--text); font-weight: 500;}
.log-ticker {font-family: var(--mono); color: var(--text);}
.log-msg {color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}

/* Drawer */
#node-drawer {position: fixed; margin: 0 0 0 auto; inset: 0; max-width: min(620px,100%); width: 620px; max-height: 100dvh; height: 100dvh; border: 0; border-left: 1px solid var(--line); padding: 28px; overflow: auto; color: var(--text); background: var(--surface); box-shadow: -24px 0 60px -24px #1c1e2440;}
#node-drawer::backdrop {background: #1c1e2433; backdrop-filter: blur(2px);}
.drawer-heading {display: flex; justify-content: space-between; gap: 20px; align-items: flex-start;}
.drawer-heading h2 {margin: 4px 0 20px; font-size: 26px; letter-spacing: -.02em;}
.drawer-close {min-width: 44px; min-height: 44px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 50%; font-size: 22px; color: var(--text); cursor: pointer; transition: transform 160ms var(--ease);}
.drawer-close:active {transform: scale(.95);}
#drawer-ticker-label {margin-bottom: 20px; color: var(--muted);}
#node-drawer pre {white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 var(--mono); max-height: 420px; overflow: auto; background: var(--surface-2); color: var(--text); padding: 16px; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line);}
#node-drawer details {margin: 22px 0;}
#node-drawer summary {min-height: 44px; padding: 10px 0;}
.finding-lead {font-size: 17px; line-height: 1.7; color: var(--text);}
.measured-features {display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; margin: 20px 0;}
.measured-features dt {font-size: 12px; color: var(--muted); overflow-wrap: anywhere; text-transform: capitalize;}
.measured-features dd {font: 18px var(--mono); margin: 3px 0; color: var(--text);}
.evidence-fragment {padding: 16px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere;}
.evidence-fragment span {display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px;}
.evidence-fragment a {font-size: 14px; line-height: 1.6;}
.model-note {font-size: 12px; color: var(--muted);}
#execution-events {padding-left: 20px; font-size: 13px; line-height: 1.6; color: var(--muted);}
#execution-events li {margin: 18px 0; overflow-wrap: anywhere;}
#execution-events strong {color: var(--text);}

/* Other views inherit the dark theme */
.research-app .panel,.research-app .workspace {background: var(--surface); border: 1px solid var(--line); border-radius: 14px;}
.research-app h2,.research-app h3 {color: var(--text);}
.research-app .control-panel p,.research-app .panel-header p,.research-app .empty-state,.research-app .inline-summary,.research-app .overview span {color: var(--muted);}
.research-app .overview article {border-left: 2px solid var(--accent-mid);}
.research-app input,.research-app select {background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px;}
.research-app input[type=range] {accent-color: var(--accent);}
.research-app input[type=checkbox] {accent-color: var(--accent);}
.research-app input::file-selector-button {background: var(--accent-soft); color: var(--accent); border: 1px solid #c9d2f5;}
.research-app label {color: var(--muted);}
.research-app .button {border-radius: 999px; transition: transform 160ms var(--ease), background 160ms ease;}
.research-app .button.primary:not(.run-research) {background: var(--accent); border-color: var(--accent); color: #fff;}
@media (hover: hover) and (pointer: fine) {.research-app .button.primary:not(.run-research):hover {background: var(--accent-hi);}}
.research-app .button.secondary {background: transparent; color: var(--text); border: 1px solid var(--line-2);}
@media (hover: hover) and (pointer: fine) {.research-app .button.secondary:hover {background: var(--accent-soft);}}
.research-app .button:active {transform: scale(.97);}
.research-app[data-input=keyboard] .button:active,.research-app[data-input=keyboard] .workflow-node:active .orb {transform: none;}
.research-app table {color: var(--text);}
.research-app th {background: var(--surface-2); color: var(--muted);}
.research-app th,.research-app td {border-bottom-color: var(--line);}
@media (hover: hover) and (pointer: fine) {.research-app tbody tr:hover {background: var(--accent-soft);}}
.research-app .table-scroll {scrollbar-color: var(--line-2) transparent;}
.research-app .ticker-link {color: var(--accent);}
.research-app .risk-tag,.research-app .provider-badge {border-color: var(--line-2); color: var(--muted);}
.research-app .control-panel details {border-top-color: var(--line);}
.research-app pre {color: var(--text);}
.research-app footer {border-top-color: var(--line); color: var(--dim); font-size: 12px;}
.research-app footer a {color: var(--muted);}
.research-app :focus-visible {outline-color: var(--accent);}
.research-app .button:focus-visible,.research-app button:focus-visible {outline: 2px solid var(--accent); outline-offset: 3px;}
.source-lab {padding: 20px 0;}
.provider-row {display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--line);}
.provider-row small {display: block; max-width: 80ch; font-size: 13px; line-height: 1.6; color: var(--muted);}
.provider-badge {font-size: 12px; padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 999px;}
.book-ladder>div {display: flex; justify-content: space-between; gap: 20px; padding: 6px; border-bottom: 1px solid var(--line); font-family: var(--mono);}
.bid {color: var(--good);}
.ask {color: var(--bad);}
.research-app [hidden] {display: none!important;}


@media(max-width:1100px) {
  .hud-lower {grid-template-columns: 1fr; gap: 32px;}
}
@media(max-width:800px) {
  .research-app .topbar {padding: 12px 16px; gap: 10px; flex-wrap: wrap;}
  .research-app .research-main {padding: 0 16px;}
  .research-nav {order: 3; flex-basis: 100%;}
  .research-app .legacy-link {margin-left: auto;}
  .desk-toolbar h1 {font-size: 22px;}
  .desk-metadata #run-time {display: none;}
}
@media(max-width:1000px) {
  #workflow-graph {min-width: 1100px;}
  .graph-scroll {padding: 0 0 8px;}
  .hud-head::after {content: 'Scroll the graph sideways · select a dial for details'; flex-basis: 100%; font-size: 12px; color: var(--dim);}
  .graph-legend span:last-child {margin-left: 0;}
  .mobile-node-picker {display: flex; font-size: 12px; color: var(--muted); margin: 10px 0 4px;}
  .mobile-node-picker select {min-height: 44px; max-width: 100%;}
}
@media(max-width:450px) {
  .desk-toolbar {align-items: flex-start; flex-direction: column; gap: 12px; margin: 18px 0 12px;}
  .run-box {align-items: flex-start;} .run-estimate, .run-steps {text-align: left;} .run-steps ol {min-width: 0;}
  .run-research {width: 100%; justify-content: center;}
  .research-app .research-main {padding: 0 12px;}
  .replay-bar {width: 100%;}
  #replay-scrub {width: 100%;}
  #node-drawer {padding: 18px;}
  .hud {padding: 14px 12px; border-radius: 16px;}
  .briefing,.run-outcome,.live-log {padding: 16px 14px;}
  .measured-features {gap: 12px;}
  .provider-row {align-items: flex-start; flex-direction: column;}
  .outcome-actions {flex-direction: column; align-items: flex-start;}
  .log-row {grid-template-columns: 7.5ch 8ch minmax(0,1fr);}
  .log-ticker {display: none;}
  .research-nav button {min-width: max-content;}
}
@media(prefers-reduced-motion:reduce) {
  .sig[open] .sig-body {transition: opacity 200ms ease;}
  @starting-style {.sig[open] .sig-body {transform: none;}}
  .orb,.tick,.workflow-node,.research-app .button,.ghost-button,.run-research,.hud::before {transition: none;}
  .run-research[data-busy] .run-dot {animation: none;}
  .workflow-node:active .orb,.research-app .button:active,.ghost-button:active {transform: none;}
}
.showcase-note {font-size: 12px; color: var(--muted); margin: 4px 0 0;}

/* Leftover light-theme pieces from the shared stylesheet, re-set for the dark app */
.research-app .eyebrow {color: var(--accent)!important; letter-spacing: 0;}

.research-app .secondary {background: transparent;}
.research-app #status {background: var(--surface-2); color: var(--muted); border-color: var(--line);}
.research-app .badge {background: var(--good-soft); color: var(--good);}
.research-app .badge.review {background: var(--amber-soft); color: var(--amber-text);}
.research-app .ticker-tag,.research-app .interval {background: var(--surface-2); color: var(--muted);}
.research-app .sentiment-bar {background: var(--line);}
.research-app .sentiment-tag.bullish {background: var(--good-soft); border-color: #bfe3cf;}
.research-app .sentiment-tag.bearish {background: var(--bad-soft); border-color: #f1c9c2;}

.research-app .research-details pre,.research-app .agent-grid pre,.research-app #quality-detail pre {background: var(--surface-2); border-radius: 10px; padding: 14px;}
.research-app .research-nav button[aria-current] {color: var(--text); box-shadow: none; font-weight: 600;}
.research-app .view th,.research-app th {background: var(--surface-2);}
