#xray-toggle { position: fixed; z-index: 30; top: max(16px, env(safe-area-inset-top)); left: 16px; border: 2px solid var(--ink); border-radius: var(--pill); padding: 10px 20px; background: var(--lime); color: var(--ink); box-shadow: var(--shadow-sm); font: 600 16px var(--body); cursor: pointer; }
body.xray-active { overflow: auto; height: auto; background: var(--bg); color: var(--fg); font-family: var(--ui); }
.xray-active .stage { display: none !important; }
#xray-page { box-sizing: border-box; max-width: 1100px; margin: auto; padding: calc(85px + env(safe-area-inset-top)) 24px 48px; font: 16px/1.5 var(--ui); }
#xray-page[hidden] { display: none; }
#xray-page h1 { font: 400 clamp(2rem,5vw,2.8rem)/1 var(--display); text-transform: uppercase; color: var(--ink); margin: 0 0 6px; }
.xray-nodes { list-style: none; padding: 0; display: flex; align-items: stretch; gap: 22px; }
.xray-nodes li { flex: 1; position: relative; min-width: 0; }
#xray-flow li:not(:last-child)::after { content: '→'; position: absolute; right: -19px; top: 40%; color: var(--link); }
.xray-nodes button, .xray-nodes li > div { box-sizing: border-box; width: 100%; height: 100%; padding: 18px 12px; text-align: left; color: inherit; background: var(--card); border: 2px solid var(--ink); border-radius: var(--r-lg); box-shadow: var(--shadow); font: 600 1rem var(--body); }
.xray-nodes button { cursor: pointer; }
.xray-nodes button[aria-pressed=true] { border-color: var(--ink); background: var(--lime); }
#xray-page button:focus-visible, #xray-toggle:focus-visible { outline: var(--focus); outline-offset: 3px; }
@media(max-width: 700px) { #xray-flow { flex-direction: column; } #xray-flow li:not(:last-child)::after { content: '↓'; top: auto; right: 50%; bottom: -23px; } }

.xray-nodes li[hidden], #xray-conversation[hidden] { display: none; }
.xray-nodes.focused { max-width: 560px; margin: 32px auto 0; }
#xray-flow.focused li::after { display: none; }
.xray-nodes.focused button { min-height: 180px; text-align: center; font-size: 24px; }
.voice-indicator { display: none; }
[aria-pressed=true] .voice-indicator { display: block; width: 14px; height: 14px; margin: 24px auto 0; border-radius: 50%; background: var(--muted); }
[aria-pressed=true][data-voice-state=listening] .voice-indicator { background: var(--ok); animation: voice-pulse 1.5s ease-in-out infinite; }
[aria-pressed=true][data-voice-state=speaking] .voice-indicator { background: var(--orange); animation: voice-pulse .6s ease-in-out infinite; }
[aria-pressed=true][data-voice-state=thinking] .voice-indicator { background: var(--pink); }
#xray-conversation { position: relative; max-width: 560px; margin: 12px auto; padding-top: 34px; }
#xray-conversation > button { position: absolute; right: 0; top: 0; width: 44px; height: 44px; border: 0; background: transparent; color: inherit; font-size: 22px; cursor: pointer; }
#xray-transcript { max-height: 45vh; overflow-y: auto; overflow-wrap: anywhere; white-space: pre-wrap; }
@keyframes voice-pulse { 50% { box-shadow: 0 0 0 10px rgba(232,70,11,.25); } }
@media(prefers-reduced-motion: reduce) { .voice-indicator { animation: none !important; } }
#xray-architect { max-width: 560px; margin: 24px auto 36px; }
.xray-nodes[hidden] { display: none; }

.xray-nodes li { display: flex; flex-direction: column; }
.xray-nodes .agent-model, .xray-nodes .agent-voice { height: auto; min-height: 44px; padding: 6px; margin-top: 4px; border: 0; background: transparent; color: var(--deep); font: 600 13px var(--body); text-align: center; }
.xray-nodes.focused .agent-model, .xray-nodes.focused .agent-voice { min-height: 44px; font-size: 16px; }
#xray-model-picker { max-width: min(420px, 85vw); border: 2px solid var(--ink); border-radius: var(--r-lg); background: var(--cream); color: var(--ink); box-shadow: var(--shadow-lg); padding: 24px; font-family: var(--body); }
#xray-model-picker::backdrop { background: rgba(28,28,28,.55); }
#xray-model-picker button { min-height: 44px; cursor: pointer; color: var(--ink); background: var(--card); border: 2px solid var(--ink); border-radius: var(--r); padding: 8px 12px; font: 600 .95rem var(--body); }
#xray-model-picker > button { float: right; }
#xray-model-picker div { display: grid; gap: 8px; }
#xray-model-picker [aria-pressed=true] { background: var(--lime); box-shadow: var(--shadow-sm); }
#xray-model-picker button:disabled { opacity: .6; cursor: default; }

/* One split control per agent: voice on the left, model pickers on the right. */
#xray-flow { flex-direction: column; max-width: 640px; margin: 24px auto; }
#xray-architect { max-width: 640px; }
#xray-flow li:not(:last-child)::after { content: '↓'; top: auto; right: 50%; bottom: -23px; }
.xray-nodes li > .agent-control { display: flex; align-items: stretch; padding: 0; overflow: hidden; }
#xray-page .agent-control > [data-agent], #xray-page .agent-control > div { flex: 1; min-width: 0; width: auto; border: 0; border-radius: 0; white-space: nowrap; padding: 16px 12px; }
#xray-page .xray-nodes .agent-model, #xray-page .xray-nodes .agent-voice { flex: 0 0 auto; width: auto; margin: 0; padding: 8px; border: 0; border-left: 2px solid var(--ink); border-radius: 0; text-align: right; white-space: nowrap; font-size: 12px; }
#xray-page .xray-nodes.focused .agent-model, #xray-page .xray-nodes.focused .agent-voice { font-size: 12px; min-height: 44px; }
.xray-nodes.focused [data-agent] { font-size: 18px; }
@media(max-width: 420px) {
  #xray-page { padding-left: 12px; padding-right: 12px; }
  #xray-page .agent-control > [data-agent] { padding: 16px 8px; font-size: 14px; }
  #xray-page .xray-nodes .agent-model, #xray-page .xray-nodes .agent-voice { padding: 8px 5px; font-size: 11px; }
}

#xray-model-picker { max-height: 85dvh; overflow-y: auto; }
#xray-model-picker .model-price-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; }
#xray-model-picker .model-price-option small { white-space: nowrap; font-size: 11px; font-variant-numeric: tabular-nums; }
#xray-model-picker .model-price-key { font-size: 12px; opacity: .85; }
#xray-model-picker .model-price-key a { color: inherit; }
#xray-model-picker .voice-filter { width: 100%; box-sizing: border-box; margin: 0 0 8px; padding: 8px; font-size: 16px; }
#xray-model-picker h3 { margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; opacity: .75; }
#xray-model-picker > div:has(.voice-filter) { max-height: 60vh; overflow-y: auto; }
/* Rows with many controls (the producer: model, voice, narration, video, music) wrap their controls under the name. */
#xray-page .agent-control:has(> :nth-child(4)) { flex-wrap: wrap; }
#xray-page .agent-control:has(> :nth-child(4)) > [data-agent] { flex: 1 0 100%; }
#xray-page .agent-control:has(> :nth-child(4)) > .agent-model, #xray-page .agent-control:has(> :nth-child(4)) > .agent-voice { flex: 1 1 auto; border-top: 2px solid var(--ink); }
@media (max-width: 520px) {
  #xray-page .agent-control { flex-wrap: wrap; }
  #xray-page .agent-control > [data-agent] { flex: 1 0 100%; }
  #xray-page .agent-control > .agent-model, #xray-page .agent-control > .agent-voice { flex: 1 1 auto; border-top: 2px solid var(--ink); }
}

/* Node page (2026-11-18): one node of the flow, pushed like a detail view. Talk/Stop is the primary action. */
#xray-page.node-open #xray-channel { display: none; }
#xray-node[hidden] { display: none; }
#xray-node { max-width: 760px; margin: 0 auto; }
#xray-node .xray-back { min-height: 44px; padding: 8px 0; border: 0; background: none; color: var(--deep); font: 600 17px var(--body); cursor: pointer; }
#xray-node .xray-talk { display: block; width: 100%; min-height: 56px; margin: 16px 0 8px; border: 2px solid var(--ink); border-radius: var(--pill); background: var(--lime); color: var(--ink); box-shadow: var(--shadow); font: 400 1.25rem/1 var(--display); text-transform: uppercase; padding-top: 4px; cursor: pointer; }
#xray-node .xray-talk[aria-pressed=true] { background: var(--deep); color: #fff; }
#xray-node .xray-talk[data-voice-state=listening] { animation: voice-pulse 1.5s ease-in-out infinite; }
#xray-node .xray-talk:disabled { background: #e9e7da; color: var(--muted); box-shadow: none; cursor: default; }
#xray-node .xray-talk-state { min-height: 1.5em; margin: 0 0 8px; color: var(--deep); font-family: var(--body); text-align: center; }
#xray-node .xray-node-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
#xray-node .xray-node-controls button { min-height: 44px; padding: 8px 14px; border: 2px solid var(--ink); border-radius: var(--pill); background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); font: 600 14px var(--body); cursor: pointer; }
#xray-node .xray-node-controls button[hidden] { display: none; }
#xray-node details { border: 2px solid var(--ink); border-radius: var(--r); background: var(--card); margin: 8px 0; }
#xray-node summary { min-height: 44px; display: flex; align-items: center; padding: 0 14px; cursor: pointer; font: 600 1rem var(--body); }
#xray-node pre { margin: 0; padding: 12px 14px; max-height: 50vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.45 ui-monospace, Menlo, monospace; }
#xray-node h2 { font: 400 1.5rem/1 var(--display); text-transform: uppercase; margin: 28px 0 8px; }
#xray-node .xray-runs { list-style: none; padding: 0; margin: 0; }
#xray-node .xray-runs > li { border-top: 2px dashed var(--line); padding: 12px 0; }
#xray-node .xray-runs h3 { font: 600 15px var(--body); margin: 0 0 6px; }
#xray-node .xray-runs h3 a, #xray-node .xray-runs details a { color: var(--link); }
#xray-node .xray-runs h4 { font: 600 12px var(--body); text-transform: uppercase; letter-spacing: .05em; opacity: .75; margin: 8px 0 2px; }
#xray-node .xray-runs details a { display: inline-block; padding: 8px 14px 12px; }
@media (prefers-reduced-motion: reduce) { #xray-node .xray-talk { animation: none !important; } }

/* Prompt editing on the node page (admins) */
.xray-prompt-part { margin: .5rem 0; }
.xray-prompt-label { margin: .25rem 0; font-size: .85em; opacity: .8; }
.xray-prompt-editbtn, .xray-prompt-form button, .xray-prompt-versions button { min-height: 44px; padding: 0 .9rem; }
.xray-prompt-form { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.xray-prompt-text { box-sizing: border-box; width: 100%; min-height: 18rem; font: .85rem/1.4 ui-monospace, monospace; padding: .6rem; resize: vertical; }
.xray-prompt-why { flex: 1 1 12rem; min-height: 44px; box-sizing: border-box; padding: 0 .6rem; }
.xray-prompt-saved { font: 600 1rem var(--body); }
.xray-prompt-versions { padding-left: 1.2rem; }
.xray-prompt-versions li { margin: .4rem 0; overflow-wrap: anywhere; }
.xray-prompt-versions pre { white-space: pre-wrap; max-height: 16rem; overflow: auto; }

/* Left-to-right flow (2026-11-18): one horizontal row in channel-DB flow order, architect above it.
   Each card: node name (opens the node page), then its model link(s) underneath (open the model picker).
   Narrow widths scroll the row sideways instead of wrapping into a column. */
#xray-flow { flex-direction: row; flex-wrap: nowrap; max-width: none; margin: 24px 0; gap: 28px; overflow-x: auto; padding: 4px 4px 12px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
#xray-flow li { flex: 0 0 168px; scroll-snap-align: start; }
#xray-flow li:not(:last-child)::after { content: '→'; top: 50%; right: -22px; bottom: auto; transform: translateY(-50%); font-size: 18px; }
#xray-architect { max-width: 220px; margin: 24px auto 8px; }
#xray-architect li::after { content: '↓'; position: absolute; left: 50%; bottom: -26px; color: var(--deep); }
#xray-page .xray-nodes .agent-control, #xray-page .xray-nodes .agent-control:has(> :nth-child(4)) { flex-direction: column; flex-wrap: nowrap; height: 100%; }
#xray-page .xray-nodes .agent-control > [data-agent], #xray-page .xray-nodes .agent-control > div { flex: 0 0 auto; width: 100%; white-space: normal; text-align: center; padding: 14px 10px 4px; }
#xray-page .xray-nodes .agent-control > .agent-model, #xray-page .xray-nodes .agent-control:has(> :nth-child(4)) > .agent-model { flex: 0 0 auto; width: 100%; min-height: 32px; padding: 4px 8px; border: 0; text-align: center; white-space: normal; font: 600 12px var(--body); color: var(--deep); text-decoration: underline; text-underline-offset: 3px; }
#xray-page .xray-nodes .agent-control > .agent-model:last-child { padding-bottom: 12px; }
#xray-page .xray-nodes .agent-control > .agent-model:hover { color: var(--ink); }
#xray-page .xray-pool { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-bottom: 14px !important; }
#xray-page .pool-duration { font-variant-numeric: tabular-nums; color: var(--deep); }
@media (max-width: 520px) { #xray-flow li { flex-basis: 140px; } #xray-page .xray-nodes .agent-control > [data-agent] { font-size: 14px; } }
/* the name button must not fill the card, or the model links below it are clipped */
#xray-page .xray-nodes .agent-control > [data-agent], #xray-page .xray-nodes .agent-control > .agent-model, #xray-page .xray-nodes .agent-control > div { height: auto; }
#xray-page .xray-nodes .agent-control { background: var(--card); border: 2px solid var(--ink); border-radius: var(--r-lg); box-shadow: var(--shadow); }
#xray-page .xray-nodes .agent-control > .agent-model { background: transparent; }
#xray-page .xray-nodes .agent-control > [data-agent] { background: transparent; }
#xray-page:not(.node-open) { max-width: 1320px; }
#xray-flow li { flex-basis: 148px; }
@media (max-width: 520px) { #xray-flow li { flex-basis: 136px; } }
#xray-flow { gap: 24px; } #xray-flow li { flex-basis: 140px; } #xray-flow li:not(:last-child)::after { right: -19px; }
#xray-page .xray-nodes .agent-model { overflow-wrap: anywhere; }
/* simka.cat style for the node page's prompt editor and other plain controls (tokens in /simka.css). */
#xray-page :is(.xray-prompt-editbtn, .xray-prompt-form button, .xray-prompt-versions button) { font: 600 .95rem var(--body); border: 2px solid var(--ink); border-radius: var(--pill); background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); cursor: pointer; }
#xray-page .xray-prompt-form button:first-of-type { background: var(--ink); color: var(--cream); box-shadow: 3px 3px 0 var(--lime); }
#xray-page :is(.xray-prompt-text, .xray-prompt-why, input, select, textarea, .voice-filter) { border: 2px solid var(--ink); border-radius: var(--r); background: var(--card); color: var(--ink); font-family: var(--body); }
#xray-page .xray-prompt-text { font-family: var(--mono); }
#xray-page button:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
#xray-page #xray-channel { font: 600 1.4rem/1 var(--hand); color: var(--deep); margin: 0; }
#xray-page .xray-prompt-label, #xray-page .xray-runs h4 { color: var(--muted); opacity: 1; }
#xray-node pre { background: var(--cream); border-top: 2px solid var(--ink); border-radius: 0 0 var(--r) var(--r); }
#xray-page .agent-control > * { box-shadow: none; }
#xray-page .agent-control > button:hover { background: var(--lime); }
#xray-heading:focus { outline: none; }
#xray-node .xray-back, #xray-conversation > button { box-shadow: none; }
/* Pool page: clips waiting to air (site/xray.js openPool) */
.xray-pool[role=button] { cursor: pointer; }
.xray-pool[role=button]:hover, .xray-pool[role=button]:focus-visible { outline: 3px solid var(--deep); outline-offset: 2px; }
#xray-pool-page[hidden] { display: none; }
#xray-pool-page { max-width: 760px; margin: 0 auto; }
#xray-pool-page .xray-back { min-height: 44px; padding: 8px 0; border: 0; background: none; color: var(--deep); font: 600 17px var(--body); cursor: pointer; }
#xray-pool-page .xray-pool-summary { font: 600 17px var(--body); margin: 8px 0; }
.xray-clips { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
@media (max-width: 420px) { .xray-clips { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }
.xray-clip { min-width: 0; }
.xray-clip-thumb { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; background: #111; box-shadow: var(--shadow-sm); cursor: pointer; }
.xray-clip-thumb:hover, .xray-clip-thumb:focus-visible { outline: 3px solid var(--deep); outline-offset: 2px; }
.xray-clip-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.xray-clip-thumb img.missing { visibility: hidden; }
.xray-clip-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 40px; height: 40px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font: 16px/40px var(--body); text-align: center; opacity: .85; }
.xray-clip-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: 4px; }
.xray-clip-meta { margin: 0; font: 13px/1.3 var(--body); min-width: 0; }
.xray-clip-delete { flex: none; min-width: 40px; min-height: 40px; border: 0; border-radius: 50%; background: none; font-size: 18px; cursor: pointer; opacity: .75; }
.xray-clip-delete:hover:not(:disabled) { opacity: 1; background: #fde2e2; }
.xray-clip-delete:disabled { opacity: .25; cursor: default; }
.xray-clip-box { width: min(960px, 100vw - 16px); max-width: none; padding: 0; border: 0; border-radius: 12px; background: #000; overflow: visible; }
.xray-clip-box::backdrop { background: rgba(0,0,0,.8); }
.xray-clip-box video { display: block; width: 100%; max-height: 85vh; border-radius: 12px; background: #000; }
.xray-clip-close { position: absolute; right: 6px; top: 6px; z-index: 1; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255,255,255,.9); color: #000; font-size: 20px; cursor: pointer; }
/* the feed's pill button style (.channel-feed button:not(...)) outranks single-class rules: reset it for the pool grid */
#xray-pool-page .xray-clips button.xray-clip-thumb { padding: 0; border-radius: 12px; box-shadow: var(--shadow-sm); background: #111; }
#xray-pool-page .xray-clips button.xray-clip-delete { padding: 0; border: 0; border-radius: 50%; box-shadow: none; background: none; }
body.channel-feed dialog.xray-clip-box button.xray-clip-close { padding: 0; border: 0; border-radius: 50%; box-shadow: none; background: rgba(255,255,255,.9); }
/* every step a card runs (agents with their model, code steps), runner order */
#xray-page .xray-nodes .agent-control > .agent-steps { list-style: none; margin: 2px 0 0; padding: 0 6px 6px; width: 100%; font: 500 11px/1.35 var(--body); color: var(--deep); text-align: left; }
#xray-page .xray-nodes .agent-control > .agent-steps li { overflow-wrap: anywhere; opacity: .85; }

/* "How this video was made" (site/xray-trace.js) */
.xray-clip-info { background: none; border: 1px solid currentColor; border-radius: 50%; width: 2rem; height: 2rem; cursor: pointer; color: inherit; font-size: 1rem; margin-left: auto; }
.xray-clip-made { display: block; margin: .5rem auto 0; background: #222; color: #fff; border: 1px solid #555; border-radius: 6px; padding: .4rem .8rem; cursor: pointer; }
.xray-trace { width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 1rem 1.25rem; border: none; border-radius: 10px; background: var(--bg, #111); color: var(--fg, #eee); }
.xray-trace::backdrop { background: rgba(0,0,0,.6); }
.xray-trace h2 { margin: 0 2.5rem .25rem 0; font-size: 1.25rem; }
.xray-trace-sub, .xray-trace-note { opacity: .75; font-size: .85rem; margin: .25rem 0; }
.xray-trace-flow { list-style: none; padding: 0; margin: .75rem 0; }
.xray-trace-step { border: 1px solid rgba(128,128,128,.4); border-radius: 8px; margin: .4rem 0; padding: .35rem .6rem; }
.xray-trace-step.failed { border-color: #c44; }
.xray-trace-step.review { border-color: #c9a227; }
.xray-trace-step > summary { cursor: pointer; display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.xray-trace-n { display: inline-block; min-width: 1.5rem; text-align: center; font-weight: 700; opacity: .7; }
.xray-trace-facts { opacity: .7; font-size: .85rem; }
.xray-trace-call, .xray-trace-part { margin: .4rem 0 .4rem 1rem; }
.xray-trace-call > summary, .xray-trace-part > summary { cursor: pointer; font-size: .9rem; }
.xray-trace-call.failed > summary { color: #e66; }
.xray-trace h4, .xray-trace h5 { margin: .5rem 0 .2rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; opacity: .8; }
.xray-trace-text { white-space: pre-wrap; word-break: break-word; max-height: 22rem; overflow: auto; background: rgba(128,128,128,.12); padding: .5rem; border-radius: 6px; font-size: .8rem; margin: .2rem 0; }
.xray-trace-media { display: block; max-width: 100%; max-height: 320px; border-radius: 6px; margin: .3rem 0; }
.xray-trace-more { background: none; border: 1px solid rgba(128,128,128,.6); color: inherit; border-radius: 6px; padding: .2rem .6rem; cursor: pointer; font-size: .8rem; }
.xray-trace-error { color: #e66; font-size: .85rem; }
.xray-trace-critique { background: rgba(201,162,39,.12); border-radius: 6px; padding: .5rem .75rem; }
.xray-trace-critique li { margin: .3rem 0; }
@media (max-width: 600px) { .xray-trace { padding: .75rem; } .xray-trace-call, .xray-trace-part { margin-left: 0; } }
