/* AGNX landing: the standalone hero with its robot, then the pinned agent stage and the chapters that scroll past it.
   Base tokens, nav, buttons, FAQ, form and footer live in index.html. */
:root { --ease-out: cubic-bezier(.16, 1, .3, 1); --stage-top: clamp(3rem, 8vh, 5rem); --stage-h: min(33rem, calc(100vh - 2 * var(--stage-top))); --chapter-h: calc(var(--stage-h) + 2 * var(--stage-top)); }

/* ---- Hero: full-width opener above the story; the stage begins with the first chapter. ---- */
.hero { min-height: calc(100svh - 80px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); align-items: center; gap: clamp(2rem, 5vw, 4rem); padding-block: clamp(3rem, 8vh, 5rem); }
.hero-inner { max-width: 44rem; }

/* Hero art: a robot colleague. It floats, looks around, blinks, scans its visor and now and
   then waves; the chest carries the AGNX mark. All CSS, stopped under reduced motion. */
.hero-art { justify-self: end; width: 100%; max-width: 32rem; --bot-glow: #22c55e; --bot-visor: #0e1a13; --bot-eye: #4ade80; --bot-metal: #eef0f2; --bot-edge: #c9ccd2; }
[data-theme="dark"] .hero-art { --bot-glow: #4ade80; --bot-visor: #07100b; --bot-eye: #86efac; --bot-metal: #2c2c30; --bot-edge: #4a4a52; }
.hero-art svg { display: block; width: 100%; height: auto; overflow: visible; }
.bot { animation: bot-float 5s ease-in-out infinite; }
.bot-shadow { fill: var(--foreground); opacity: .08; transform-box: fill-box; transform-origin: center; animation: bot-shadow 5s ease-in-out infinite; }
.bot-shell { fill: var(--bot-metal); stroke: var(--bot-edge); stroke-width: 2; }
.bot-shell-hi { fill: var(--card); opacity: .7; }
.bot-visor { fill: var(--bot-visor); }
.bot-eyes { animation: bot-look 8s ease-in-out infinite; }
.bot-eye { fill: var(--bot-eye); filter: url(#bot-glow-strong); transform-box: fill-box; transform-origin: center; animation: bot-blink 5s infinite; }
.bot-scan { fill: url(#bot-scan); animation: bot-scan 2.8s linear infinite; }
.bot-antenna { stroke: var(--bot-edge); stroke-width: 4; stroke-linecap: round; }
.bot-antenna-tip { fill: var(--bot-glow); filter: url(#bot-glow-strong); animation: bot-beacon 1.6s ease-in-out infinite; }
.bot-neck, .bot-bolt { fill: var(--bot-edge); }
.bot-core { transform-box: fill-box; transform-origin: center; animation: bot-core 2.4s ease-in-out infinite; }
.bot-mark-hex { fill: none; stroke: var(--brand); stroke-width: 7; }
.bot-mark-chev { fill: none; stroke: var(--bot-glow); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; filter: url(#bot-glow); }
.bot-led { fill: var(--bot-glow); animation: bot-led 1.2s var(--d, 0s) ease-in-out infinite; }
.bot-arm-wave { transform-box: fill-box; transform-origin: 20% 10%; animation: bot-wave 6s ease-in-out infinite; }
@keyframes bot-float { 50% { transform: translateY(-10px); } }
@keyframes bot-shadow { 50% { transform: scaleX(.86); opacity: .05; } }
@keyframes bot-blink { 0%, 44%, 48%, 100% { transform: scaleY(1); } 46% { transform: scaleY(.1); } }
@keyframes bot-look { 0%, 20% { transform: translateX(0); } 28%, 45% { transform: translateX(-9px); } 55%, 72% { transform: translateX(9px); } 80%, 100% { transform: translateX(0); } }
@keyframes bot-scan { from { transform: translateY(-80px); } to { transform: translateY(80px); } }
@keyframes bot-beacon { 50% { opacity: .35; } }
@keyframes bot-core { 50% { transform: scale(1.06); } }
@keyframes bot-led { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes bot-wave { 0%, 60%, 100% { transform: rotate(0); } 66% { transform: rotate(-22deg); } 72% { transform: rotate(-6deg); } 78% { transform: rotate(-22deg); } 86% { transform: rotate(0); } }
@media (prefers-reduced-motion: reduce) { .hero-art *, .hero-art { animation: none !important; } .bot-scan { display: none; } }

/* ---- Story layout: copy column + sticky stage column ---- */
.story-grid { display: flex; align-items: flex-start; gap: clamp(3rem, 6vw, 5.5rem); }
.story-copy { flex: 0 1 46%; min-width: 0; position: relative; }
.story-stage-col { flex: 1 1 54%; min-width: 0; position: sticky; top: 0; height: var(--chapter-h); display: flex; align-items: flex-start; padding-top: var(--stage-top); }
.chapter { min-height: calc(var(--chapter-h) * 1.6); scroll-margin-top: 0; }
.chapter-inner { position: sticky; top: 0; height: var(--chapter-h); display: flex; flex-direction: column; justify-content: center; padding-block: 1.5rem; }
.hero h1 { font-size: clamp(2.6rem, 3.6vw, 3.4rem); line-height: 1.04; }
.hero h1 span { color: var(--brand); white-space: nowrap; }
.hero .lede { max-width: 42ch; color: var(--muted-foreground); font-size: 1.15rem; line-height: 1.6; margin-top: 1.5rem; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 1.5rem; margin-top: 1.75rem; }
.hero-actions .btn-brand { min-height: 52px; padding-inline: 1.6rem; }
.hero-note { color: var(--muted-foreground); font-size: .78rem; margin-top: 1.25rem; }
.chapter h2 { line-height: 1.08; }
.chapter-lede { max-width: 40ch; color: var(--muted-foreground); font-size: 1.15rem; line-height: 1.65; margin-top: 1.25rem; }
.proof-caption { max-width: 44ch; color: var(--muted-foreground); font-size: .78rem; line-height: 1.6; margin-top: 1.25rem; }

/* Body copy is justified; headings, labels and controls stay left-aligned. */
.hero .lede, .chapter-lede, .proof-caption, .trace-event p, .demo-copy > p, .faq-list details p { text-align: justify; hyphens: auto; }

/* The run line: a hairline between copy and stage that fills as the story advances. */
.story-copy::before, .story-copy::after { content: ''; position: absolute; top: 0; bottom: 0; right: calc(-1 * clamp(1.5rem, 3vw, 2.75rem)); width: 1px; }
.story-copy::before { background: var(--border); }
.story-copy::after { background: var(--brand); transform-origin: top; transform: scaleY(var(--story-progress, 0)); }
.chapter-inner::before { content: ''; position: absolute; right: calc(-1 * clamp(1.5rem, 3vw, 2.75rem) - 4px); top: 50%; width: 9px; height: 9px; border-radius: 50%; background: var(--background); border: 1px solid var(--border); transition: background .3s, border-color .3s; }
.chapter.is-active .chapter-inner::before { background: var(--brand); border-color: var(--brand); }

/* ---- Stage frame ---- */
.stage { position: relative; width: 100%; height: var(--stage-h); border-radius: 20px; background: var(--stage); box-shadow: var(--elevation); overflow: hidden; }
.stage-layers { position: absolute; inset: 0; }
.stage-mark { position: absolute; left: 0; top: 0; width: 56px; height: 64px; z-index: 5; pointer-events: none; transform-origin: 0 0; opacity: 0; transition: transform .8s var(--ease-out), opacity .25s ease; }
.stage-mark.is-placed { opacity: 1; }
.stage-mark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mark-hex { stroke: var(--mark-outline); }
.mark-chevron { stroke: #16a34a; }
.mark-dot { fill: #16a34a; transform-origin: 132px 153px; transform-box: view-box; }
.mark-arc { stroke: #16a34a; stroke-dasharray: var(--mark-len, 720); stroke-dashoffset: var(--mark-len, 720); opacity: 0; }
.stage.is-working .mark-arc { opacity: 1; animation: mark-sweep 1.4s .25s cubic-bezier(.45, 0, .2, 1) both; }
.stage.is-working .mark-dot { animation: mark-pulse .9s ease-in-out 2; }
@keyframes mark-sweep { from { stroke-dashoffset: var(--mark-len, 720); } to { stroke-dashoffset: 0; } }
@keyframes mark-pulse { 50% { transform: scale(1.9); } }
.js .stage .mark-anchor img { visibility: hidden; }

/* Panels: inline demonstrations without JavaScript; layers of the stage with it. */
.panel { display: flex; flex-direction: column; border-radius: 16px; background: var(--stage); overflow: hidden; margin-top: 2.5rem; }
.panel-slot:empty { display: none; }
.stage .panel { position: absolute; inset: 0; margin: 0; border-radius: 0; background: transparent; opacity: 0; visibility: hidden; transform: translateY(14px) scale(.985); filter: blur(6px); transition: opacity .3s ease, transform .3s ease, filter .3s ease, visibility 0s linear .3s; }
.stage .panel.is-active { opacity: 1; visibility: visible; transform: none; filter: none; transition: opacity .55s var(--ease-out) .1s, transform .75s var(--ease-out) .1s, filter .55s var(--ease-out) .1s, visibility 0s; }
.panel-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; justify-content: flex-start; }
.panel-body > * { flex-shrink: 0; }
.panel-work .panel-body { justify-content: center; }
.panel-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.5rem; padding: .5rem 1rem .5rem 1.25rem; border-bottom: 1px solid var(--border); font-size: .78rem; color: var(--muted-foreground); }
.panel-bar-start, .panel-bar-end { display: flex; align-items: center; gap: .75rem; }
.panel-bar-note { text-align: right; }
.proof-button { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .8rem; color: var(--foreground); background: var(--card); cursor: pointer; min-height: 40px; font: inherit; font-size: .78rem; transition: border-color .18s, color .18s; }
.proof-button:hover { border-color: var(--brand); color: var(--brand); }
.proof-label { display: block; color: var(--muted-foreground); font-size: .78rem; margin-bottom: .75rem; }
.mark-anchor { display: inline-block; width: 56px; height: 64px; flex-shrink: 0; }
.mark-anchor img { display: block; width: 100%; height: 100%; }
.mark-anchor .brand-dark { display: none; }
[data-theme="dark"] .mark-anchor .brand-dark { display: block; }
[data-theme="dark"] .mark-anchor .brand-light { display: none; }
.mark-anchor-sm { width: 28px; height: 32px; }

/* Run status chip in the work panel bar. */
.run-status { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; font-weight: 500; color: var(--brand); }
.run-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.run-running { display: none; }
.panel-work[data-run="running"] .run-running { display: inline; }
.panel-work[data-run="running"] .run-done { display: none; }
.panel-work[data-run="running"] .run-status { color: var(--muted-foreground); }
.panel-work[data-run="running"] .run-dot { background: var(--muted-foreground); animation: dot-blink 1s ease-in-out infinite; }
@keyframes dot-blink { 50% { opacity: .3; } }

/* Scenario tabs (native radios). */
.scenario-tabs { display: flex; gap: .25rem; border: 0; padding: 0; margin: 0; flex-wrap: wrap; }
.scenario-tabs label { position: relative; padding: .5rem .75rem; min-height: 40px; display: flex; align-items: center; cursor: pointer; border-radius: 8px; color: var(--muted-foreground); transition: background .18s, color .18s; }
.scenario-tabs label:hover { color: var(--foreground); }
.scenario-tabs label:has(:checked) { background: var(--card); color: var(--brand); box-shadow: 0 1px 2px rgb(0 0 0 / .06); }
.scenario-tabs label:has(:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.scenario-tabs input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scenario-panel { display: none; }
.panel-work:has(input[value="0"]:checked) [data-scenario="0"], .panel-work:has(input[value="1"]:checked) [data-scenario="1"], .panel-work:has(input[value="2"]:checked) [data-scenario="2"] { display: block; }

/* Work composition: incoming records → agent → result sheet. */
.work-composition { display: grid; grid-template-columns: minmax(0, 1fr) 4.5rem minmax(0, 1.15fr); gap: 1rem; align-items: center; padding: 1.5rem 1.5rem 1rem; }
.incoming-message h3 { font-size: 1.15rem; letter-spacing: -.02em; }
.source-records, .result-records { list-style: none; padding: 0; margin: 1rem 0 0; }
.source-records li { display: flex; justify-content: space-between; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--border); font-size: .85rem; }
.source-records strong { font-weight: 500; font-variant-numeric: tabular-nums; }
.work-path { display: flex; align-items: center; flex-direction: column; gap: .6rem; align-self: center; }
.path-label { color: var(--brand); font-size: .78rem; text-align: center; white-space: nowrap; }
.work-path .connector { width: 100%; height: 1px; background: var(--brand); transform-origin: left; }
.reply-sheet { padding: 1.35rem 1.35rem 1rem; background: var(--card); border-radius: 12px; box-shadow: 0 16px 40px -24px rgb(0 0 0 / .35); }
.reply-sheet h3 { font-size: 1.45rem; line-height: 1.12; letter-spacing: -.03em; }
.reply-sheet > p { margin-top: .5rem; color: var(--muted-foreground); font-size: .85rem; }
.result-records li { display: flex; align-items: flex-start; gap: .65rem; border-top: 1px solid var(--border); padding: .7rem 0; font-size: .85rem; }
.row-text { display: grid; gap: .15rem; min-width: 0; }
.result-records strong { font-weight: 500; }
.result-records span span { color: var(--muted-foreground); font-size: .78rem; }
.row-icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: .1rem; fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[data-row="review"] .row-icon, [data-row="skip"] .row-icon { stroke: var(--muted-foreground); }
.work-progress { display: grid; grid-template-columns: repeat(3, 1fr); list-style: none; counter-reset: work; padding: 0 1.5rem 1.25rem; margin: 0; gap: 1rem; }
.work-progress li { counter-increment: work; border-top: 1px solid var(--brand); padding-top: .6rem; font-size: .78rem; color: var(--foreground); }
.work-progress li::before { content: '0' counter(work); margin-right: .5rem; color: var(--brand); font-variant-numeric: tabular-nums; }

/* Lens trace. */
.proof-wordmark { color: var(--foreground); font-size: 1.15rem; letter-spacing: -.04em; }
.trace-overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; padding: 1.5rem; background: var(--card); }
.trace-overview .proof-label { margin-bottom: .35rem; }
.trace-overview strong { display: block; font-size: 1.5rem; font-weight: 500; letter-spacing: -.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trace-overview > div:first-child strong { color: var(--brand); }
.trace-events { padding: .25rem 1.5rem 1rem; }
.trace-event { border-bottom: 1px solid var(--border); }
.trace-event summary { display: grid; grid-template-columns: 1.6rem 1.1fr 1fr 3.4rem .9rem; gap: .75rem; align-items: center; cursor: pointer; padding: .95rem 0; font-size: .9rem; }
.trace-event summary::after { grid-column: 5; grid-row: 1; }
.event-index, .event-duration { color: var(--muted-foreground); font-size: .78rem; font-variant-numeric: tabular-nums; }
.event-duration { text-align: right; }
.trace-bar { display: block; height: 6px; position: relative; background: var(--card); border-radius: 999px; }
.trace-bar::after { content: ''; display: block; position: absolute; left: var(--event-offset); width: var(--event-width); height: 100%; background: var(--brand); border-radius: 999px; transform-origin: left; }
.stage .panel-lens.is-active .trace-bar::after { animation: bar-grow .7s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * .1s); }
@keyframes bar-grow { from { transform: scaleX(0); } }
.trace-event summary:hover, .trace-event[open] summary { color: var(--brand); }
.trace-event p { margin: 0 0 1rem 2.35rem; color: var(--muted-foreground); max-width: 60ch; font-size: .85rem; line-height: 1.65; }

/* Lifecycle. */
.launch-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 0; padding: 0; margin: 0; }
.launch-steps label { display: flex; position: relative; align-items: center; gap: .6rem; padding: 1rem 1.25rem; cursor: pointer; color: var(--muted-foreground); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .18s, border-color .18s; font-size: .85rem; }
.launch-steps label:hover { color: var(--foreground); }
.launch-steps label:has(:checked) { color: var(--brand); border-bottom-color: var(--brand); }
.launch-steps label:has(:focus-visible) { outline: 2px solid var(--brand); outline-offset: -4px; }
.launch-steps input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.launch-number { font-variant-numeric: tabular-nums; font-size: .78rem; }
.launch-panels { display: grid; }
.launch-panel { display: none; grid-template-columns: .85fr 1.15fr; gap: 2.5rem; padding: 2.75rem 2rem 2rem; align-content: start; }
.panel-launch:has(input[value="0"]:checked) [data-launch-panel="0"], .panel-launch:has(input[value="1"]:checked) [data-launch-panel="1"], .panel-launch:has(input[value="2"]:checked) [data-launch-panel="2"] { display: grid; animation: panel-in .5s var(--ease-out) both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } }
.launch-label { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.launch-label .proof-label { margin: 0; }
.launch-story h3 { font-size: 2.25rem; line-height: 1.12; letter-spacing: -.03em; }
.launch-story p { margin-top: 1.1rem; color: var(--muted-foreground); line-height: 1.65; font-size: 1rem; }
.launch-settings { margin: 0; align-self: start; padding-top: .25rem; }
.launch-settings > div { display: flex; justify-content: space-between; gap: 1rem; padding: 1.1rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.launch-settings dd { white-space: nowrap; }
.launch-settings dt { color: var(--muted-foreground); }
.launch-settings dd { margin: 0; text-align: right; font-weight: 500; }

/* ---- No JavaScript: the chapters keep their demonstrations inline. ---- */
.no-js .story-stage-col { display: none; }
.no-js .story-grid { display: block; }
.no-js .chapter { min-height: 0; padding-block: clamp(3rem, 6vw, 5rem); }
.no-js .story-copy::before, .no-js .story-copy::after, .no-js .chapter-inner::before { display: none; }
.no-js .chapter-inner { position: static; height: auto; padding: 0; }
.no-js .replay-only { display: none; }

/* ---- Compact: stage pinned to the top, chapters read beneath it. ---- */
@media (max-width: 880px) {
  :root { --stage-h: min(56vh, 31rem); }
  .story-grid { flex-direction: column; gap: 0; }
  .story-copy { flex: none; width: 100%; }
  .story-copy::before, .story-copy::after, .chapter-inner::before { display: none; }
  .chapter-inner { position: static; height: auto; padding: 0; }
  .story-stage-col { order: -1; flex: none; width: 100%; height: auto; display: block; z-index: 20; padding-block: .5rem .75rem; background: var(--background); }
  .stage { border-radius: 16px; }
  .chapter { min-height: 0; padding-block: 2.75rem; scroll-margin-top: calc(var(--stage-h) + 2rem); }
  .story-stage-col { padding-top: .5rem; height: auto; }
  .hero { min-height: calc(100svh - 72px); grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .hero h1 { font-size: 2.25rem; }
  .chapter h2 { font-size: 2rem; }
  .chapter-lede, .hero .lede { font-size: 1rem; }
  .panel-bar { min-height: 3rem; padding: .35rem .75rem .35rem .9rem; }
  .proof-button { min-height: 36px; padding: .35rem .6rem; font-size: .78rem; }
  .run-status { font-size: .78rem; }
  .scenario-tabs label { padding: .35rem .5rem; min-height: 36px; font-size: .78rem; }
  .scenario-tabs { flex-wrap: nowrap; }
  .panel-bar { flex-wrap: nowrap; }
  .work-composition { grid-template-columns: minmax(0, .85fr) 2.4rem minmax(0, 1.15fr); gap: .6rem; padding: .9rem .9rem .6rem; }
  .work-path .path-label { display: none; }
  .source-records strong, .result-records strong { white-space: nowrap; }
  .mark-anchor { width: 34px; height: 39px; }
  .mark-anchor-sm { width: 24px; height: 27px; }
  .path-label { font-size: .78rem; }
  .incoming-message h3 { font-size: .9rem; }
  .source-records li, .result-records li { font-size: .78rem; padding: .45rem 0; gap: .5rem; }
  .source-records, .result-records { margin-top: .6rem; }
  .reply-sheet { padding: .8rem .85rem .4rem; }
  .reply-sheet h3 { font-size: 1.15rem; }
  .reply-sheet > p { font-size: .78rem; margin-top: .3rem; }
  .result-records span span { font-size: .78rem; }
  .row-icon { width: 15px; height: 15px; }
  .work-progress { padding: 0 .9rem .8rem; gap: .5rem; }
  .work-progress li { font-size: .78rem; padding-top: .4rem; }
  .trace-overview { grid-template-columns: repeat(4, 1fr); gap: .5rem; padding: .9rem; }
  .trace-overview strong { font-size: 1.15rem; }
  .trace-overview .proof-label { font-size: .78rem; margin-bottom: .2rem; }
  .trace-events { padding: 0 .9rem .5rem; }
  .trace-event summary { grid-template-columns: 1.3rem 1fr 2.8rem .8rem; gap: .5rem; padding: .65rem 0; font-size: .78rem; }
  .trace-bar { display: none; }
  .trace-event summary::after { grid-column: 4; }
  .trace-event p { margin: 0 0 .75rem 1.8rem; font-size: .78rem; }
  .launch-steps label { padding: .6rem .5rem; font-size: .78rem; gap: .35rem; flex-direction: column; align-items: flex-start; }
  .launch-panel { grid-template-columns: 1fr; gap: 1rem; padding: 1rem .9rem; }
  .launch-story h3 { font-size: 1.15rem; }
  .launch-story p { font-size: .85rem; margin-top: .5rem; }
  .launch-settings > div { padding: .45rem 0; font-size: .78rem; }
}
@media (max-width: 540px) {
  .hero-note { margin-inline: 0; max-width: none; }
  .panel-bar-end { gap: .4rem; }
  #replay-work { display: none; }
  .trace-overview { grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
}
@media (max-height: 700px) and (min-width: 881px) {
  :root { --stage-h: calc(100vh - 3rem); }
  .story-stage-col { height: 100vh; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
