:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1d2430;
  --muted: #5b6778;
  --line: #d9dee7;
  --accent: #265dab;
  --accent-ink: #ffffff;
  --danger: #a92d2d;
  --current: #e5f0ff;
  --current-line: #265dab;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f;
    --panel: #1c222c;
    --ink: #e8edf5;
    --muted: #9aa7ba;
    --line: #343d4c;
    --accent: #6fa8ff;
    --accent-ink: #10151c;
    --danger: #ff8a8a;
    --current: #233552;
    --current-line: #6fa8ff;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar h1 { font-size: 1.15rem; margin: 0; }
.subtitle { color: var(--muted); font-weight: 400; font-size: .95rem; }
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.login-panel { max-width: 520px; margin: 3rem auto; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
.grid.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
input, select, button { font: inherit; border-radius: 7px; border: 1px solid var(--line); padding: .45rem .6rem; background: var(--panel); color: var(--ink); }
input:focus, select:focus, button:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); cursor: pointer; }
button.secondary { background: transparent; color: var(--ink); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }
.badge { border: 1px solid var(--line); border-radius: 999px; padding: .15rem .6rem; font-size: .8rem; color: var(--muted); }
.muted { color: var(--muted); font-size: .85rem; }
.error { color: var(--danger); min-height: 1.2em; }
.notice { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: .75rem; margin: .75rem 0; display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; background: var(--current); }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; max-height: 260px; overflow: auto; }
.list button { width: 100%; text-align: left; background: transparent; color: var(--ink); border-color: var(--line); display: flex; justify-content: space-between; gap: .5rem; }
.list button.selected { border-color: var(--accent); background: var(--current); }
.list .meta { color: var(--muted); font-size: .8rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin: .5rem 0; }
.facts dt { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: .1rem 0 0; font-weight: 600; }
.controls { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0 .25rem; }
#graph-svg { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.graph-node rect { fill: var(--panel); stroke: var(--line); stroke-width: 1.2; }
.graph-node.current rect { fill: var(--current); stroke: var(--current-line); stroke-width: 2.4; }
.graph-node text { fill: var(--ink); font-size: 11px; pointer-events: none; }
.graph-node { cursor: default; }
.graph-edge { stroke: var(--muted); stroke-width: 1; opacity: .42; fill: none; }
.graph-edge.current { stroke: var(--current-line); opacity: .95; stroke-width: 2; }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th, .table td { text-align: left; border-bottom: 1px solid var(--line); padding: .35rem .4rem; vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; }
.events { list-style: none; padding: 0; margin: .25rem 0; max-height: 320px; overflow: auto; font-size: .8rem; }
.events li { border-bottom: 1px solid var(--line); padding: .3rem 0; }
.events code { font-size: .78rem; overflow-wrap: anywhere; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Research navigation, views and result/architecture/presentation rendering. */
.tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 1rem; padding: .25rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.tab { background: transparent; color: var(--ink); border-color: transparent; padding: .45rem .8rem; }
.tab:hover { border-color: var(--line); }
.tab.active, .tab[aria-current="page"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.view { display: block; }
.summary { margin: .75rem 0; line-height: 1.45; }
.empty { border: 1px dashed var(--line); border-radius: 8px; padding: .9rem; background: var(--bg); color: var(--muted); }
.table-wrap { overflow-x: auto; }
.table td.repro-cell { min-width: 260px; }
.repro { display: inline-block; max-width: 420px; overflow-wrap: anywhere; font-size: .78rem; }
.badge.ok { border-color: var(--accent); color: var(--accent); }
.badge.warn { border-color: #b8860b; color: #8a6508; }
.badge.bad { border-color: var(--danger); color: var(--danger); }
.badge.neutral { color: var(--muted); }
.artifact { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.artifact .meta { margin-left: auto; }
.list.plain { max-height: none; }
.list.plain li { padding: .15rem 0; overflow-wrap: anywhere; }
.pipeline { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .75rem 0; }
.pipeline button.stage { background: transparent; color: var(--ink); border-color: var(--line); }
.pipeline button.stage.active { background: var(--current); border-color: var(--accent); }
.stage-detail { border-top: 1px solid var(--line); padding-top: .75rem; margin-top: .5rem; }
.stage-detail h3 { margin-top: .2rem; }
.stage-detail h4 { margin: .8rem 0 .25rem; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.presentation #presentation-narration { font-size: 1.05rem; line-height: 1.55; max-width: 70ch; }
button.link { background: transparent; color: var(--accent); border: none; padding: 0; text-decoration: underline; cursor: pointer; text-align: left; }
button.small { padding: .15rem .45rem; font-size: .75rem; }
.facts.aggregate { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.facts.aggregate dt { text-transform: none; letter-spacing: 0; }
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; }
  .tabs { gap: .25rem; }
  .tab { padding: .4rem .55rem; font-size: .85rem; }
  main { padding: .5rem; }
  .facts { grid-template-columns: 1fr 1fr; }
  .presentation #presentation-narration { font-size: 1rem; }
}
.repro-cell button { margin-left: .4rem; }

/* ===== Workflow Studio ===================================================== */
.mode { display: inline-flex; align-items: center; gap: .25rem; border-radius: 999px; padding: .05rem .5rem; font-size: .66rem; font-weight: 800; letter-spacing: .08em; border: 1px solid; line-height: 1.5; }
.mode.LIVE { color: #34d399; border-color: rgba(52,211,153,.55); background: rgba(52,211,153,.12); box-shadow: 0 0 12px rgba(52,211,153,.35); }
.mode.LIVE::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #34d399; animation: s-blink 1.6s infinite; }
.mode.REPLAY { color: #93c5fd; border-color: rgba(147,197,253,.55); background: rgba(147,197,253,.12); }
.mode.MOCK { color: #cbd5e1; border-color: rgba(203,213,225,.4); background: rgba(203,213,225,.08); }
.mode.UNAVAILABLE { color: #fbbf24; border-color: rgba(251,191,36,.5); background: rgba(251,191,36,.1); }
.mode.OPERATOR { color: #c4b5fd; border-color: rgba(196,181,253,.55); background: rgba(196,181,253,.12); }
@keyframes s-blink { 50% { opacity: .25; } }
@keyframes s-pulse { 0% { box-shadow: 0 0 0 0 rgba(251,191,36,.55); } 70% { box-shadow: 0 0 0 12px rgba(251,191,36,0); } 100% { box-shadow: 0 0 0 0 rgba(251,191,36,0); } }
@keyframes s-spin { to { transform: rotate(360deg); } }
@keyframes s-flow { to { stroke-dashoffset: -24; } }
@keyframes s-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#view-studio, #view-studio [hidden] { }
#view-studio[hidden], #view-studio [hidden] { display: none !important; }
.studio {
  --s-bg: #070b18; --s-card: rgba(17, 25, 48, .78); --s-line: rgba(148,163,184,.16); --s-ink: #e6ebf7; --s-muted: #94a3b8;
  --s-accent: #7c8cff; --s-accent2: #22d3ee; --s-ok: #34d399; --s-bad: #f87171; --s-warn: #fbbf24;
  color: var(--s-ink); background:
    radial-gradient(1200px 500px at 10% -10%, rgba(124,140,255,.25), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(34,211,238,.16), transparent 60%), var(--s-bg);
  border-radius: 18px; padding: 1.4rem; border: 1px solid var(--s-line);
}
.studio code { color: #c7d2fe; }
.studio-hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1.5rem; align-items: center; padding: .6rem .4rem 1.2rem; }
@media (max-width: 960px) { .studio-hero { grid-template-columns: 1fr; } }
.eyebrow { text-transform: uppercase; letter-spacing: .18em; font-size: .7rem; color: var(--s-accent2); font-weight: 700; }
.studio-hero h2 { font-size: 2.1rem; margin: .3rem 0 .5rem; letter-spacing: -.02em;
  background: linear-gradient(90deg, #fff, #c7d2fe 45%, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.studio-hero p { color: var(--s-muted); line-height: 1.55; margin: 0; max-width: 52ch; }
.pipeline-steps { list-style: none; display: flex; margin: 0; padding: 0; gap: 0; }
.pipeline-steps li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .4rem; position: relative; color: var(--s-muted); font-size: .76rem; text-align: center; }
.pipeline-steps li::before { content: ""; position: absolute; top: 17px; left: -50%; width: 100%; height: 2px; background: var(--s-line); z-index: 0; }
.pipeline-steps li:first-child::before { display: none; }
.pipeline-steps .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; z-index: 1;
  background: #0f172a; border: 2px solid var(--s-line); color: var(--s-muted); transition: all .35s; }
.pipeline-steps li.active { color: var(--s-ink); }
.pipeline-steps li.active .dot { border-color: var(--s-warn); color: var(--s-warn); animation: s-pulse 1.8s infinite; }
.pipeline-steps li.done { color: var(--s-ink); }
.pipeline-steps li.done .dot { background: linear-gradient(135deg, var(--s-accent), var(--s-accent2)); border-color: transparent; color: #0b1020; }
.pipeline-steps li.done::before, .pipeline-steps li.active::before { background: linear-gradient(90deg, var(--s-accent), var(--s-accent2)); }
.pipeline-steps li.failed .dot { background: var(--s-bad); border-color: var(--s-bad); color: #fff; }
.pipeline-steps li.failed { color: var(--s-bad); }

.cap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .7rem; }
.cap { border: 1px solid var(--s-line); background: var(--s-card); border-radius: 12px; padding: .7rem .8rem; backdrop-filter: blur(8px); animation: s-rise .4s both; }
.cap .cap-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.cap strong { font-size: .86rem; }
.cap p { margin: .35rem 0 0; color: var(--s-muted); font-size: .74rem; line-height: 1.4; }
.cap.is-LIVE { border-color: rgba(52,211,153,.4); box-shadow: inset 0 0 0 1px rgba(52,211,153,.08), 0 8px 30px -12px rgba(52,211,153,.4); }
.legend { color: var(--s-muted); font-size: .74rem; display: flex; flex-wrap: wrap; gap: .45rem .9rem; align-items: center; margin: .8rem 0 1.1rem; }

.s-card { background: var(--s-card); border: 1px solid var(--s-line); border-radius: 16px; padding: 1.2rem 1.3rem; margin-bottom: 1rem;
  backdrop-filter: blur(10px); box-shadow: 0 20px 60px -30px rgba(0,0,0,.8); animation: s-rise .45s both; }
.s-head { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: 1rem; }
.s-head h3 { margin: 0; font-size: 1.15rem; }
.s-head p { margin: .2rem 0 0; color: var(--s-muted); font-size: .84rem; }
.s-num { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; color: #0b1020; flex: none;
  background: linear-gradient(135deg, var(--s-accent), var(--s-accent2)); }
.s-sub { margin: 1.3rem 0 .6rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--s-muted); }
.s-note { color: var(--s-muted); font-size: .8rem; margin: .4rem 0; }
.s-error { color: var(--s-bad); min-height: 1em; font-size: .85rem; margin: .4rem 0 0; }

.example-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .6rem; margin-bottom: .9rem; }
.example { text-align: left; background: rgba(15,23,42,.6); border: 1px solid var(--s-line); color: var(--s-ink); border-radius: 12px; padding: .7rem .8rem;
  cursor: pointer; display: flex; flex-direction: column; gap: .35rem; transition: transform .15s, border-color .15s, box-shadow .15s; }
.example:hover { transform: translateY(-2px); border-color: rgba(124,140,255,.6); }
.example.selected { border-color: var(--s-accent); box-shadow: 0 0 0 1px var(--s-accent), 0 10px 30px -12px rgba(124,140,255,.7); }
.example strong { font-size: .86rem; }
.example span.snippet { color: var(--s-muted); font-size: .74rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag { align-self: flex-start; font-size: .64rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; border-radius: 6px; padding: .05rem .4rem; }
.tag.pass { color: var(--s-ok); background: rgba(52,211,153,.12); }
.tag.fail { color: var(--s-bad); background: rgba(248,113,113,.12); }
.tag.custom { color: var(--s-accent2); background: rgba(34,211,238,.12); }

.studio textarea, .studio input, .studio select { background: rgba(2,6,23,.6); color: var(--s-ink); border: 1px solid var(--s-line); border-radius: 10px; font: inherit; }
.studio textarea { width: 100%; box-sizing: border-box; padding: .75rem .85rem; font-size: .95rem; line-height: 1.45; resize: vertical; }
.studio textarea:focus, .studio input:focus, .studio select:focus { outline: 2px solid var(--s-accent); outline-offset: 1px; }
.spec-form { display: flex; flex-direction: column; gap: .7rem; }
.spec-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin: .4rem 0; }
.spec-actions .grow, .waiting-banner .grow { flex: 1; }
.studio .field { display: flex; flex-direction: column; gap: .25rem; font-size: .72rem; color: var(--s-muted); text-transform: uppercase; letter-spacing: .08em; }
.studio .field input, .studio .field select { padding: .5rem .6rem; text-transform: none; letter-spacing: 0; font-size: .88rem; }
.toggle { display: inline-flex; align-items: center; gap: .5rem; color: var(--s-ink); font-size: .84rem; cursor: pointer; flex-direction: row; padding-bottom: .4rem; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { width: 36px; height: 20px; border-radius: 99px; background: #334155; position: relative; transition: background .2s; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + .track { background: var(--s-accent); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.studio button.cta { background: linear-gradient(135deg, var(--s-accent), var(--s-accent2)); color: #0b1020; border: none; font-weight: 800; padding: .6rem 1.1rem; border-radius: 10px;
  box-shadow: 0 8px 24px -8px rgba(124,140,255,.8); transition: transform .12s, box-shadow .12s; }
.studio button.cta:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 30px -8px rgba(34,211,238,.8); }
.studio button.ghost, .studio button.danger-ghost { background: transparent; color: var(--s-ink); border: 1px solid var(--s-line); border-radius: 10px; padding: .55rem .9rem; }
.studio button.ghost:hover:not(:disabled) { border-color: var(--s-accent); }
.studio button.danger-ghost { color: var(--s-bad); border-color: rgba(248,113,113,.4); }
.studio button:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }

.job { margin-top: 1rem; border-top: 1px dashed var(--s-line); padding-top: .9rem; }
.job-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .85rem; color: var(--s-muted); }
.pill { border-radius: 999px; padding: .1rem .6rem; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; border: 1px solid var(--s-line); color: var(--s-muted); }
.pill.succeeded { color: var(--s-ok); border-color: rgba(52,211,153,.5); background: rgba(52,211,153,.1); }
.pill.rejected, .pill.failed { color: var(--s-bad); border-color: rgba(248,113,113,.5); background: rgba(248,113,113,.1); }
.pill.unavailable { color: var(--s-warn); border-color: rgba(251,191,36,.5); }
.pill.running, .pill.queued, .pill.submitting { color: var(--s-accent2); border-color: rgba(34,211,238,.5); }
.stage-track { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
@media (max-width: 800px) { .stage-track { grid-template-columns: 1fr 1fr; } }
.stage-track li { border: 1px solid var(--s-line); border-radius: 10px; padding: .55rem .65rem; background: rgba(2,6,23,.45); font-size: .76rem; color: var(--s-muted); animation: s-rise .3s both; }
.stage-track li .st-name { display: flex; align-items: center; gap: .4rem; color: var(--s-ink); font-weight: 700; text-transform: capitalize; margin-bottom: .2rem; }
.stage-track li .icon { width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .62rem; flex: none; }
.stage-track li.done { border-color: rgba(52,211,153,.4); }
.stage-track li.done .icon { background: var(--s-ok); color: #052e1c; }
.stage-track li.running .icon { border: 2px solid var(--s-accent2); border-top-color: transparent; animation: s-spin .8s linear infinite; }
.stage-track li.failed, .stage-track li.unavailable { border-color: rgba(248,113,113,.45); }
.stage-track li.failed .icon, .stage-track li.unavailable .icon { background: var(--s-bad); color: #fff; }
.stage-track li.skipped { opacity: .45; }
.stage-track li.skipped .icon { background: #334155; }

.verdict { display: flex; gap: 1rem; align-items: center; border-radius: 14px; padding: 1rem 1.1rem; margin-bottom: .9rem; }
.verdict .v-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; font-weight: 900; flex: none; }
.verdict .v-title { font-size: 1.15rem; font-weight: 800; }
.verdict .v-sub { color: var(--s-muted); font-size: .82rem; margin-top: .15rem; }
.verdict ul { margin: .35rem 0 0; padding-left: 1.1rem; color: #fecaca; font-size: .82rem; }
.verdict.yes { background: linear-gradient(90deg, rgba(52,211,153,.18), rgba(52,211,153,.03)); border: 1px solid rgba(52,211,153,.45); }
.verdict.yes .v-icon { background: var(--s-ok); color: #052e1c; box-shadow: 0 0 30px rgba(52,211,153,.6); }
.verdict.no { background: linear-gradient(90deg, rgba(248,113,113,.2), rgba(248,113,113,.03)); border: 1px solid rgba(248,113,113,.5); }
.verdict.no .v-icon { background: var(--s-bad); color: #fff; box-shadow: 0 0 30px rgba(248,113,113,.55); }
.fact-strip { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
.fact { border: 1px solid var(--s-line); border-radius: 8px; padding: .3rem .55rem; font-size: .74rem; background: rgba(2,6,23,.4); }
.fact span { color: var(--s-muted); margin-right: .35rem; }
.fact b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; color: #c7d2fe; }
.policy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .6rem; }
.policy-card { border: 1px solid var(--s-line); border-radius: 12px; padding: .75rem .85rem; background: rgba(2,6,23,.45); display: flex; flex-direction: column; gap: .35rem; animation: s-rise .35s both; }
.policy-card .p-top { display: flex; justify-content: space-between; align-items: center; }
.policy-card .p-id { font-size: 1.3rem; font-weight: 900; letter-spacing: -.02em; }
.policy-card .p-state { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; border-radius: 6px; padding: .1rem .45rem; }
.policy-card .p-rule { color: var(--s-muted); font-size: .8rem; line-height: 1.35; }
.policy-card.satisfied { border-color: rgba(52,211,153,.3); }
.policy-card.satisfied .p-id { color: var(--s-ok); }
.policy-card.satisfied .p-state { color: var(--s-ok); background: rgba(52,211,153,.12); }
.policy-card.violated { border-color: rgba(248,113,113,.6); background: linear-gradient(180deg, rgba(248,113,113,.14), rgba(2,6,23,.45)); box-shadow: 0 0 0 1px rgba(248,113,113,.25), 0 12px 30px -16px rgba(248,113,113,.8); }
.policy-card.violated .p-id { color: var(--s-bad); }
.policy-card.violated .p-state { color: #fff; background: var(--s-bad); }
.policy-card .p-diag { font-size: .76rem; color: #fecaca; border-top: 1px dashed rgba(248,113,113,.35); padding-top: .35rem; }

.graph-wrap { border: 1px solid var(--s-line); border-radius: 14px; background:
  linear-gradient(rgba(148,163,184,.06) 1px, transparent 1px) 0 0 / 22px 22px,
  linear-gradient(90deg, rgba(148,163,184,.06) 1px, transparent 1px) 0 0 / 22px 22px, rgba(2,6,23,.55); overflow-x: auto; margin: .6rem 0; }
svg.flow-graph { width: 100%; min-width: 760px; height: auto; display: block; }
.flow-graph text { font-family: inherit; fill: var(--s-ink); }
.flow-graph .n-box { fill: #0f172a; stroke: rgba(148,163,184,.35); stroke-width: 1.4; }
.flow-graph .n-title { font-size: 13px; font-weight: 700; }
.flow-graph .n-sub { font-size: 10.5px; fill: var(--s-muted); }
.flow-graph .n-badge { font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.flow-graph .b-LIVE rect { fill: rgba(52,211,153,.15); stroke: #34d399; } .flow-graph .b-LIVE text { fill: #34d399; }
.flow-graph .b-MOCK rect { fill: rgba(203,213,225,.08); stroke: #64748b; } .flow-graph .b-MOCK text { fill: #cbd5e1; }
.flow-graph .b-UNAVAILABLE rect { fill: rgba(251,191,36,.1); stroke: #fbbf24; } .flow-graph .b-UNAVAILABLE text { fill: #fbbf24; }
.flow-graph .edge { stroke: rgba(148,163,184,.45); stroke-width: 2; fill: none; }
.flow-graph .edge.done { stroke: #34d399; }
.flow-graph .edge.active { stroke: #22d3ee; stroke-dasharray: 8 4; animation: s-flow .7s linear infinite; }
.flow-graph .edge.side { stroke: rgba(148,163,184,.22); stroke-width: 1.2; stroke-dasharray: 3 4; }
.flow-graph .edge.side.hot { stroke: #fbbf24; stroke-width: 2; stroke-dasharray: 6 4; animation: s-flow .7s linear infinite; }
.flow-graph .node.done .n-box { stroke: #34d399; fill: rgba(6,78,59,.45); }
.flow-graph .node.current .n-box { stroke: #22d3ee; stroke-width: 2.6; fill: rgba(8,51,68,.8); filter: drop-shadow(0 0 10px rgba(34,211,238,.8)); }
.flow-graph .node.waiting.current .n-box { stroke: #fbbf24; filter: drop-shadow(0 0 12px rgba(251,191,36,.85)); }
.flow-graph .node.terminal-ok .n-box { stroke: #34d399; }
.flow-graph .node.terminal-bad .n-box { stroke: rgba(248,113,113,.6); stroke-dasharray: 4 3; }
.flow-graph .node.violated .n-box { stroke: #f87171; stroke-width: 2.6; fill: rgba(127,29,29,.45); filter: drop-shadow(0 0 10px rgba(248,113,113,.7)); }
.flow-graph .node.violated .n-sub { fill: #fecaca; }
.flow-graph .lane-label { font-size: 10px; fill: var(--s-muted); letter-spacing: .1em; text-transform: uppercase; }

.s-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.s-table th { text-align: left; color: var(--s-muted); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; padding: .45rem .5rem; border-bottom: 1px solid var(--s-line); }
.s-table td { padding: .5rem; border-bottom: 1px solid var(--s-line); vertical-align: top; }
.s-table td code { font-size: .74rem; overflow-wrap: anywhere; }
details.ir { margin-top: 1rem; border: 1px solid var(--s-line); border-radius: 12px; padding: .6rem .8rem; background: rgba(2,6,23,.4); }
details.ir summary { cursor: pointer; color: var(--s-muted); font-size: .84rem; }
.studio pre.code { max-height: 360px; overflow: auto; background: #020617; border: 1px solid var(--s-line); border-radius: 10px; padding: .75rem; font-size: .74rem; color: #c7d2fe; }
#studio-plan-edit { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; }

.run-strip { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr; gap: .6rem; margin: .6rem 0; }
@media (max-width: 800px) { .run-strip { grid-template-columns: 1fr 1fr; } }
.run-strip > div { border: 1px solid var(--s-line); border-radius: 12px; padding: .6rem .75rem; background: rgba(2,6,23,.45); display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.run-strip span { font-size: .66rem; text-transform: uppercase; letter-spacing: .12em; color: var(--s-muted); }
.run-strip strong { font-size: 1.05rem; text-transform: capitalize; }
.run-strip code { font-size: .74rem; overflow-wrap: anywhere; }
#studio-run-state.completed, #studio-run-chain.ok { color: var(--s-ok); }
#studio-run-state.waiting, #studio-run-state.running { color: var(--s-warn); }
#studio-run-state.failed, #studio-run-chain.bad { color: var(--s-bad); }
.waiting-banner { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; border: 1px solid rgba(251,191,36,.55); background: linear-gradient(90deg, rgba(251,191,36,.16), rgba(251,191,36,.02)); border-radius: 12px; padding: .75rem .9rem; margin: .6rem 0; }
.pulse-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--s-warn); animation: s-pulse 1.4s infinite; }
.op-lane { display: flex; gap: .55rem; overflow-x: auto; padding: .4rem .1rem .6rem; margin: .6rem 0; }
.op-card { flex: 1 0 150px; border: 1px solid var(--s-line); border-radius: 12px; padding: .65rem .7rem; background: rgba(2,6,23,.5); position: relative; transition: all .3s; }
.op-card:not(:last-child)::after { content: "→"; position: absolute; right: -.52rem; top: 50%; transform: translateY(-50%); color: var(--s-muted); font-size: .8rem; z-index: 1; }
.op-card .o-top { display: flex; justify-content: space-between; align-items: center; gap: .4rem; }
.op-card .o-id { font-weight: 800; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; }
.op-card .o-prim { color: var(--s-muted); font-size: .74rem; margin: .15rem 0 .45rem; }
.op-card .o-status { display: flex; align-items: center; gap: .35rem; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.op-card .o-meta { color: var(--s-muted); font-size: .68rem; margin-top: .3rem; }
.op-card.pending { opacity: .55; }
.op-card.running { border-color: var(--s-accent2); box-shadow: 0 0 0 1px rgba(34,211,238,.4), 0 0 24px -6px rgba(34,211,238,.7); }
.op-card.running .o-status { color: var(--s-accent2); }
.op-card.waiting { border-color: var(--s-warn); animation: s-pulse 1.6s infinite; }
.op-card.waiting .o-status { color: var(--s-warn); }
.op-card.completed { border-color: rgba(52,211,153,.5); background: linear-gradient(180deg, rgba(52,211,153,.1), rgba(2,6,23,.5)); }
.op-card.completed .o-status { color: var(--s-ok); }
.op-card.failed { border-color: var(--s-bad); }
.op-card.failed .o-status { color: var(--s-bad); }

.calls { display: flex; flex-direction: column; gap: .35rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem;
  background: #020617; color: #e2e8f0; border: 1px solid rgba(148,163,184,.2); border-radius: 12px; padding: .7rem .8rem; }
.call { display: grid; grid-template-columns: 70px 84px minmax(0, 1fr) 50px 64px; gap: .5rem; align-items: baseline; padding: .25rem 0; border-bottom: 1px dashed rgba(148,163,184,.15); animation: s-rise .3s both; }
.call:last-child { border-bottom: none; }
.call .c-op { color: #c7d2fe; font-weight: 700; }
.call .c-req { overflow-wrap: anywhere; }
.call .c-req .m { font-weight: 800; margin-right: .35rem; }
.call .m-POST { color: #fbbf24; } .call .m-GET { color: #34d399; } .call .m-LOCAL { color: #94a3b8; }
.call .c-http { font-weight: 800; } .call .c-http.ok { color: #34d399; } .call .c-http.bad { color: #f87171; } .call .c-http.none { color: #64748b; }
.call .c-ms { color: #94a3b8; text-align: right; }
.call .c-sum { grid-column: 3 / -1; color: #94a3b8; font-size: .7rem; overflow-wrap: anywhere; }
.call .c-sum b { color: #e2e8f0; font-weight: 600; }
.call .c-note { color: #64748b; font-style: italic; }
.chain { display: flex; gap: .45rem; overflow-x: auto; padding: .3rem .1rem .7rem; }
.block { flex: 0 0 150px; border: 1px solid var(--s-line); border-radius: 10px; padding: .5rem .55rem; background: rgba(2,6,23,.55); font-size: .7rem; position: relative; animation: s-rise .3s both; }
.block:not(:last-child)::after { content: ""; position: absolute; right: -.5rem; top: 50%; width: .45rem; height: 2px; background: linear-gradient(90deg, var(--s-accent), var(--s-accent2)); }
.block .b-seq { color: var(--s-accent2); font-weight: 800; }
.block .b-type { font-weight: 700; margin: .15rem 0; overflow-wrap: anywhere; }
.block .b-hash { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--s-muted); font-size: .64rem; overflow-wrap: anywhere; }
.block.op-completed { border-color: rgba(52,211,153,.4); }
.block.op-waiting { border-color: rgba(251,191,36,.5); }
.block.wf-completed { border-color: #34d399; box-shadow: 0 0 18px -6px rgba(52,211,153,.8); }
.diff { display: flex; flex-direction: column; gap: .3rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; background: #020617; border: 1px solid var(--s-line); border-radius: 10px; padding: .7rem; margin-top: .6rem; }
.diff-added { color: #34d399; } .diff-removed { color: #f87171; } .diff-changed { color: #fbbf24; }
.revise { margin-top: 1rem; }
/* Adapter calls also appear in the (light) Live Lab instance view. */
#live-calls .calls { margin-top: .3rem; }

.how { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; margin: 1rem 0 .2rem; }
@media (max-width: 900px) { .how { grid-template-columns: 1fr 1fr; } }
.how > div { border: 1px solid var(--s-line); border-radius: 12px; padding: .6rem .7rem; background: rgba(2,6,23,.4); display: flex; flex-direction: column; gap: .2rem; }
.how b { font-size: .8rem; color: #c7d2fe; }
.how span { font-size: .74rem; color: var(--s-muted); line-height: 1.35; }
.explain { display: flex; gap: .65rem; align-items: flex-start; border: 1px solid rgba(124,140,255,.3); background: linear-gradient(90deg, rgba(124,140,255,.12), rgba(124,140,255,.02));
  border-radius: 12px; padding: .65rem .8rem; margin: .2rem 0 .9rem; font-size: .82rem; line-height: 1.5; color: #cbd5e1; }
.explain .i { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: .72rem; font-style: italic;
  background: linear-gradient(135deg, var(--s-accent), var(--s-accent2)); color: #0b1020; margin-top: .1rem; }
.explain strong { color: var(--s-ink); }
.explain b.ok { color: var(--s-ok); } .explain b.bad { color: var(--s-bad); }
.graph-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .74rem; color: var(--s-muted); align-items: center; margin: .2rem 0; }
.graph-legend > span { display: inline-flex; align-items: center; gap: .35rem; }
.lg { display: inline-block; width: 14px; height: 10px; border-radius: 3px; border: 2px solid; }
.lg.done { border-color: #34d399; background: rgba(6,78,59,.6); }
.lg.current { border-color: #22d3ee; background: rgba(8,51,68,.8); box-shadow: 0 0 6px #22d3ee; }
.lg.waiting { border-color: #fbbf24; }
.lg.violated { border-color: #f87171; background: rgba(127,29,29,.6); }
#studio-run-chain { text-transform: none; }
.policy-grid, .cap-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .policy-grid, .cap-grid { grid-template-columns: 1fr 1fr; } }

/* ---- Front end / back end split -------------------------------------------------- */
main:has(#view-studio:not([hidden])) { max-width: 1760px; }
.studio-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 36%); gap: 1.1rem; align-items: start; margin-top: .4rem; }
.studio-split.no-backend { grid-template-columns: minmax(0, 1fr); }
.studio-split.no-backend .backend { display: none; }
@media (max-width: 1180px) { .studio-split { grid-template-columns: 1fr; } .backend { position: static !important; max-height: none !important; } }
.studio-front { min-width: 0; }
.side-label { display: flex; align-items: center; gap: .55rem; font-size: .74rem; color: var(--s-muted); text-transform: uppercase; letter-spacing: .14em; margin: .2rem 0 .7rem; }
.side-label span { padding: .22rem .6rem; border-radius: 999px; font-weight: 800; letter-spacing: .12em; color: #0b1020; }
.side-label.front span { background: linear-gradient(90deg, #a5b4fc, #7c8cff); }
.side-label.back span { background: linear-gradient(90deg, #67e8f9, #22d3ee); }
.be-toggle { margin-top: .6rem; background: rgba(34,211,238,.12); color: #a5f3fc; border: 1px solid rgba(34,211,238,.4); border-radius: 999px; padding: .35rem .85rem; font-size: .8rem; cursor: pointer; }
.be-toggle[aria-pressed="false"] { background: transparent; color: var(--s-muted); border-color: var(--s-line); }

.backend { position: sticky; top: .8rem; max-height: calc(100vh - 1.6rem); display: flex; flex-direction: column; min-width: 0;
  background: linear-gradient(180deg, rgba(8,47,73,.55), rgba(7,11,24,.92)); border: 1px solid rgba(34,211,238,.28);
  border-radius: 16px; padding: .9rem .95rem .7rem; box-shadow: 0 0 0 1px rgba(34,211,238,.05), 0 20px 60px -30px rgba(34,211,238,.45); }
.be-head { display: flex; justify-content: space-between; gap: .8rem; align-items: flex-start; }
.be-head h3 { margin: 0; font-size: 1.05rem; color: #e0f2fe; }
.be-sub { margin: .2rem 0 .6rem; font-size: .78rem; color: var(--s-muted); line-height: 1.35; }
.be-status { white-space: nowrap; font-size: .72rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; background: rgba(148,163,184,.15); color: var(--s-muted); }
.be-status.live { background: rgba(52,211,153,.16); color: #6ee7b7; }
.be-status.live::before { content: ""; display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: #34d399; margin-right: .35rem; animation: bePulse 1.6s infinite; vertical-align: middle; }
.be-status.off { background: rgba(248,113,113,.15); color: #fca5a5; }
@keyframes bePulse { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.7); } 70% { box-shadow: 0 0 0 7px rgba(52,211,153,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); } }

.be-arch { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; counter-reset: arch; }
.be-arch li { position: relative; border: 1px solid var(--s-line); border-radius: 10px; padding: .38rem .4rem .34rem; background: rgba(15,23,42,.7); transition: all .25s ease; min-width: 0; }
.be-arch li b { display: block; font-size: .74rem; color: #e2e8f0; }
.be-arch li span { display: block; font-size: .63rem; color: var(--s-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.be-arch li i { position: absolute; top: .3rem; right: .35rem; font-style: normal; font-size: .6rem; color: var(--s-muted); }
.be-arch li.hot { transform: translateY(-2px); border-color: var(--lc); box-shadow: 0 0 0 1px var(--lc), 0 0 22px -4px var(--lc); background: color-mix(in srgb, var(--lc) 18%, #0f172a); }
.be-arch li.used { border-color: color-mix(in srgb, var(--lc) 45%, transparent); }

.be-now { display: flex; gap: .55rem; align-items: baseline; padding: .5rem .65rem; border-radius: 10px; background: rgba(2,6,23,.7); border: 1px dashed rgba(34,211,238,.35); margin-bottom: .55rem; font-size: .84rem; color: #e0f2fe; min-height: 2.4rem; }
.be-now-label { font-size: .62rem; text-transform: uppercase; letter-spacing: .14em; color: #22d3ee; font-weight: 800; }
.be-tools { display: flex; gap: .4rem; align-items: center; margin-bottom: .45rem; }
.be-filters { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.be-filters button { font-size: .64rem; padding: .14rem .45rem; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--lc) 55%, transparent); color: var(--lc); background: color-mix(in srgb, var(--lc) 10%, transparent); cursor: pointer; }
.be-filters button[aria-pressed="false"] { opacity: .35; text-decoration: line-through; }
.studio button.small { font-size: .72rem; padding: .2rem .55rem; }

.be-feed { list-style: none; margin: 0; padding: 0 .15rem 0 0; overflow-y: auto; flex: 1; min-height: 220px; font-size: .78rem; }
.be-feed li { position: relative; display: grid; grid-template-columns: 4.9rem 1fr; gap: .1rem .5rem; padding: .42rem .45rem .42rem .7rem; border-left: 3px solid var(--lc); margin-bottom: .3rem; border-radius: 0 8px 8px 0; background: rgba(15,23,42,.62); animation: beIn .35s ease; }
.be-feed li.fresh { background: color-mix(in srgb, var(--lc) 14%, rgba(15,23,42,.8)); }
@keyframes beIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
.be-feed .t { color: var(--s-muted); font-variant-numeric: tabular-nums; font-size: .68rem; padding-top: .1rem; }
.be-feed .row1 { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; min-width: 0; }
.be-feed .lay { font-size: .6rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--lc); }
.be-feed .ttl { color: #f1f5f9; font-weight: 600; word-break: break-word; }
.be-feed .hop { grid-column: 2; color: var(--s-muted); font-size: .68rem; }
.be-feed .meta { grid-column: 2; display: flex; gap: .4rem; flex-wrap: wrap; font-size: .66rem; color: #cbd5e1; }
.be-feed .meta code { font-size: .64rem; color: #a5f3fc; }
.be-feed .st { font-size: .6rem; font-weight: 800; padding: .04rem .38rem; border-radius: 999px; text-transform: uppercase; }
.be-feed .st.ok { background: rgba(52,211,153,.16); color: #6ee7b7; }
.be-feed .st.rejected, .be-feed .st.failed, .be-feed .st.bad { background: rgba(248,113,113,.18); color: #fca5a5; }
.be-feed .st.waiting, .be-feed .st.running { background: rgba(251,191,36,.16); color: #fde68a; }
.be-feed .st.unavailable { background: rgba(148,163,184,.18); color: #cbd5e1; }
.be-feed details { grid-column: 2; }
.be-feed summary { cursor: pointer; color: var(--s-muted); font-size: .64rem; }
.be-feed pre { margin: .25rem 0 0; max-height: 220px; overflow: auto; background: #020617; padding: .45rem; border-radius: 6px; font-size: .64rem; color: #cbd5e1; white-space: pre-wrap; word-break: break-all; }
.be-feed li.sys { border-left-color: #475569; color: var(--s-muted); background: transparent; }
.be-feed li.client::after { content: "this page"; position: absolute; right: .45rem; top: .4rem; font-size: .56rem; color: var(--s-muted); border: 1px solid var(--s-line); padding: 0 .3rem; border-radius: 4px; }
.be-foot { margin: .5rem 0 0; font-size: .66rem; color: var(--s-muted); line-height: 1.35; }

[data-layer="browser"]  { --lc: #c4b5fd; }
[data-layer="api"]      { --lc: #818cf8; }
[data-layer="compiler"] { --lc: #60a5fa; }
[data-layer="model"]    { --lc: #f472b6; }
[data-layer="verifier"] { --lc: #fbbf24; }
[data-layer="registry"] { --lc: #a78bfa; }
[data-layer="runtime"]  { --lc: #2dd4bf; }
[data-layer="stellar"]  { --lc: #34d399; }
[data-layer="mock"]     { --lc: #94a3b8; }
[data-layer="audit"]    { --lc: #22d3ee; }
.studio-split .op-lane { flex-wrap: wrap; overflow-x: visible; }
.studio-split .op-card { flex: 1 1 150px; min-width: 150px; }
