/* Landing page */

/* ---------- hero ---------- */
.hero { padding-block: clamp(36px, 6vw, 88px) clamp(56px, 8vw, 120px); }
.hero-grid { align-items: end; row-gap: 48px; }
.hero-copy { grid-column: 1 / span 8; }
.hero-fig { grid-column: 9 / span 4; align-self: stretch; display: flex; flex-direction: column; justify-content: flex-end; gap: 24px; }
.hero-label { margin-bottom: 28px; }
.hero h1 { font-size: clamp(3.4rem, 7.6vw, 7.8rem); line-height: 0.88; margin-bottom: 0.3em; }
.h1-mask { display: block; overflow: hidden; padding-bottom: 0.06em; margin-bottom: -0.06em; }
.h1-line { display: block; }
.js .h1-line { transform: translateY(108%); animation: rise 1.1s var(--ease) forwards; }
.js .h1-mask:nth-child(1) .h1-line { animation-delay: 0.1s; }
.js .h1-mask:nth-child(2) .h1-line { animation-delay: 0.22s; }
.js .h1-mask:nth-child(3) .h1-line { animation-delay: 0.34s; }
@keyframes rise { to { transform: none; } }
.hero-lead { max-width: 50ch; }
.js .hero-lead, .js .hero-cta, .js .hero-label { opacity: 0; animation: fadeup 0.9s var(--ease) 0.6s forwards; }
.js .hero-cta { animation-delay: 0.75s; }
@keyframes fadeup { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.hero-cta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 32px; }

#hero-svg { width: 100%; height: auto; max-height: 560px; overflow: visible; }
.hln { fill: none; stroke: var(--bone); stroke-width: 1.1; vector-effect: non-scaling-stroke; }
.hln-t { stroke: var(--bone-3); stroke-width: 1; }
.hln-faint { stroke: var(--bone-3); opacity: 0.55; stroke-dasharray: 3 5; }
.hln-arc { stroke-width: 1.5; }
.hln-acc { stroke: var(--accent); stroke-width: 2; }
.hln-angle { stroke-width: 1.5; }
.hfill { fill: var(--accent); }
.ht { font: 500 12px var(--mono); fill: var(--bone-2); letter-spacing: 0.06em; }
.ht-dim { fill: var(--bone-3); }
.js #hero-svg .hln:not(.hln-faint):not(.hln-angle):not(.hln-acc) { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.7s var(--ease-io) forwards; animation-delay: calc(var(--i, 0) * 90ms + 0.2s); }
.js #hero-svg .hln-acc, .js #hero-svg .hln-angle, .js #hero-svg .hfill, .js #hero-svg .ht, .js #hero-svg .hln-faint { opacity: 0; animation: fadein 0.8s ease 1.4s forwards; }
.js #hero-svg .hln-faint { animation-name: fadein-faint; }
@keyframes fadein { to { opacity: 1; } }
@keyframes fadein-faint { to { opacity: 0.55; } }
#hero-svg.static .hln, .reduce #hero-svg .hln { stroke-dashoffset: 0 !important; animation: none !important; opacity: 1; }
.reduce #hero-svg .hln-faint { opacity: 0.55 !important; }
.reduce #hero-svg .hln-acc, .reduce #hero-svg .ht, .reduce #hero-svg .hfill, .reduce #hero-svg .hln-angle { opacity: 1 !important; animation: none !important; }

.hero-facts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line-2); }
.hero-facts li { padding: 14px 14px 0 0; display: grid; gap: 6px; font-size: 0.85rem; line-height: 1.4; color: var(--bone-2); }
.hero-facts li + li { padding-left: 14px; border-left: 1px solid var(--line); }
.hero-facts b { font: 800 2.6rem/1 var(--display); color: var(--bone); }
.hero-facts small { font-size: 0.45em; margin-left: 2px; color: var(--bone-3); }
@media (max-width: 960px) {
  .hero-copy, .hero-fig { grid-column: 1 / -1; }
  .hero-fig { flex-direction: column-reverse; }
  #hero-svg { max-width: 360px; }
}
@media (max-width: 520px) {
  .hero-facts { grid-template-columns: 1fr; }
  .hero-facts li + li { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); padding-top: 12px; }
  .hero-facts li { padding-bottom: 12px; grid-template-columns: 5.5ch 1fr; align-items: baseline; }
  .hero-facts b { font-size: 2rem; }
}

/* ---------- stage ---------- */
.stage-wrap { height: 560vh; position: relative; border-top: 1px solid var(--line); }
.stage-pin { position: sticky; top: var(--head-h); height: calc(100dvh - var(--head-h)); display: flex; align-items: center; overflow: hidden; }
.stage-inner { display: flex; flex-direction: column; height: 100%; padding-top: 18px; gap: 6px; min-height: 0; }
.stage-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; flex: none; }
.stage-h { font-size: clamp(1.7rem, 3vw, 2.8rem); margin: 6px 0 0; max-width: 18ch; }
.stage-meter { width: min(300px, 40%); }
.stage-meter .label { margin: 0; }
.pbar { height: 2px; background: var(--line-2); margin: 8px 0; }
.pbar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }
.stage-note { font-size: 0.66rem; }
.stage { flex: 1; min-height: 0; padding: 30px 6px 46px 36px; }
.ui { position: relative; height: 100%; display: grid; gap: 10px; grid-template-columns: 200px minmax(0, 1fr) 330px; grid-template-rows: 38px minmax(0, 1fr) 184px 34px; grid-template-areas: 'title title title' 'tree editor agent' 'tree term agent' 'status status status'; }
.p-title { grid-area: title; } .p-tree { grid-area: tree; } .p-editor { grid-area: editor; } .p-agent { grid-area: agent; } .p-term { grid-area: term; } .p-status { grid-area: status; }
.p { position: relative; min-width: 0; min-height: 0; overflow: hidden; padding: 10px 12px; font: 400 0.75rem/1.55 var(--mono); color: var(--bone-2); }
.p::before { content: ''; position: absolute; inset: 0; background: var(--ink-2); opacity: var(--fill, 0); z-index: 0; }
.p > * { position: relative; z-index: 2; }
.bp { position: absolute; left: 0; top: 0; z-index: 1; overflow: visible; pointer-events: none; }
.bl { fill: none; stroke: var(--bone); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke 0.8s ease, opacity 0.8s ease; }
.bl-cross { stroke: var(--accent); }
.bl-dim { stroke: var(--bone-3); }
.bt { font: 500 10.5px var(--mono); fill: var(--bone-3); letter-spacing: 0.08em; opacity: 0; }
.ui.settled .bl-panel { stroke: var(--line-2); }
.ui.settled .bl-cross { opacity: 0.45; }
.ui.settled .bl-dim { opacity: 0.55; }

.stage [data-t0] { opacity: 0; transform: translateY(5px); transition: opacity 0.3s ease, transform 0.3s ease; }
.stage [data-t0].on { opacity: 1; transform: none; }
.ui-h { margin: 0 0 8px; font: 500 0.66rem var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--bone-3); }
.p-title { display: flex; align-items: center; gap: 14px; padding: 0 12px; }
.ui-dots { display: flex; gap: 5px; }
.ui-dots i { width: 8px; height: 8px; border: 1px solid var(--bone-3); display: block; }
.ui-title { color: var(--bone); font-weight: 500; }
.ui-modes { margin-left: auto; display: flex; gap: 2px; }
.ui-modes b { font-weight: 500; padding: 3px 9px; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--bone-3); }
.ui-modes .on { color: var(--ink); background: var(--bone); }
.tree { list-style: none; margin: 0; padding: 0; }
.tree li { padding: 2px 0; white-space: nowrap; display: flex; justify-content: space-between; gap: 8px; color: var(--bone-2); }
.tree .d { color: var(--bone); font-weight: 500; }
.tree .i1 { padding-left: 12px; } .tree .i2 { padding-left: 24px; }
.tree li[data-flag]::after { content: attr(data-flag); color: var(--accent); font-weight: 600; font-size: 0.68rem; }
.tabs { display: flex; margin: -10px -12px 8px; border-bottom: 1px solid var(--line); min-height: 28px; }
.tab { padding: 6px 14px; font-size: 0.72rem; color: var(--bone-3); border-right: 1px solid var(--line); opacity: 0; }
.stage .tab[data-t0].on { opacity: 1; }
.tab.active { color: var(--bone); box-shadow: inset 0 -2px 0 var(--accent); }
.p-editor { display: flex; flex-direction: column; }
.code-wrap { display: flex; gap: 10px; flex: 1; min-height: 0; overflow: hidden; font-size: 0.78rem; line-height: 1.7; }
.gut { margin: 0; text-align: right; color: var(--bone-3); min-width: 2ch; user-select: none; }
.scode { margin: 0; white-space: pre; color: var(--bone-2); flex: 1; min-width: 0; overflow: hidden; }
.hide { display: none; }
.scode .k { color: var(--bone); font-weight: 600; }
.scode .s { color: var(--accent); }
.scode .c { color: var(--bone-3); font-style: italic; }
.scode .t { color: var(--bone); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.caret { display: inline-block; width: 7px; height: 1.1em; background: var(--accent); vertical-align: text-bottom; margin-left: 1px; animation: blink 1s steps(1) infinite; }
.diffview { display: none; white-space: normal; }
.diffview.show { display: block; }
.diffview .dl { display: flex; gap: 12px; padding: 0 6px; white-space: pre; border-left: 2px solid transparent; }
.diffview .dl code { background: none; padding: 0; font-size: inherit; color: inherit; }
.diffview .dn { width: 2ch; text-align: right; color: var(--bone-3); flex: none; }
.stage .dl-add { max-height: calc(var(--k, 0) * 1.8em); overflow: hidden; opacity: var(--k, 0); transform: none; color: var(--bone); background: rgba(236, 228, 210, 0.09); border-left-color: var(--bone); transition: none; }
.stage .dl-add .dn { color: var(--bone); }
.stage .dl-del { opacity: 1; transform: none; }
.stage .dl-del.on { color: var(--accent); background: var(--accent-dim); border-left-color: var(--accent); text-decoration: line-through; text-decoration-color: rgba(255, 91, 31, 0.6); }
.stage .dl-del .dn { color: inherit; }

.alog { display: flex; flex-direction: column; gap: 7px; font: 400 0.72rem/1.45 var(--mono); }
.am { padding: 6px 8px; border: 1px solid var(--line); color: var(--bone-2); }
.am-user { border-color: var(--line-2); color: var(--bone); min-height: 3.2em; background: var(--ink-3); }
.am-step b { color: var(--accent); margin-right: 6px; font-weight: 600; letter-spacing: 0.06em; }
.am-step em, .am-ask em { font-style: normal; color: var(--bone-3); float: right; }
.am-step em.pass { color: var(--bone); }
.am-ask { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-color: var(--accent); border-style: dashed; color: var(--bone); }
.ask-b { display: inline-flex; gap: 4px; flex: none; }
.ask-b u { text-decoration: none; border: 1px solid var(--line-2); padding: 1px 7px; font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--bone-3); }
.ask-b.flipped u.allow { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.am-done { border-color: var(--bone-3); color: var(--bone); }
.term { margin: 0; font: 400 0.74rem/1.6 var(--mono); white-space: pre; color: var(--bone-2); overflow: hidden; }
.term .pass { color: var(--bone); }
.p-status { display: flex; align-items: center; gap: clamp(12px, 3vw, 36px); padding: 0 12px; font-size: 0.72rem; }
.st-mode { color: var(--ink); background: var(--accent); padding: 2px 8px; font-weight: 600; letter-spacing: 0.08em; }
.st-item { display: inline-flex; gap: 8px; align-items: baseline; }
.st-item b { color: var(--bone); font-weight: 500; }
.st-free { margin-left: auto; }

.stage-wrap.static { height: auto; }
.stage-wrap.static .stage-pin { position: static; height: auto; padding-block: 56px; }
.stage-wrap.static .stage { height: 640px; flex: none; }

@media (max-width: 1100px) { .ui { grid-template-columns: 170px minmax(0, 1fr) 290px; } }
@media (max-width: 860px) {
  .stage-wrap { height: 480vh; }
  .stage-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .stage-h { font-size: 1.5rem; max-width: none; margin: 2px 0 0; }
  .stage-meter { width: 100%; }
  .stage-note { display: none; }
  .stage { padding: 20px 4px 30px 4px; }
  .ui { grid-template-columns: minmax(0, 1fr); grid-template-rows: 32px minmax(0, 1fr) 132px 92px 30px; grid-template-areas: 'title' 'editor' 'agent' 'term' 'status'; gap: 8px; }
  .p-tree { display: none; }
  .ui-modes b:not(.on) { display: none; }
  .ui-title { display: none; }
  .p { padding: 8px 10px; font-size: 0.68rem; }
  .code-wrap { font-size: 0.68rem; line-height: 1.6; }
  .alog { font-size: 0.66rem; gap: 5px; }
  .am { padding: 4px 6px; }
  .am-user { min-height: 0; }
  .term { font-size: 0.66rem; line-height: 1.5; }
  .st-item .label { display: none; }
  .st-free .label { display: inline; }
  .stage-wrap.static .stage { height: 560px; }
}

/* ---------- modes walkthrough ---------- */
.modes-wrap { height: 460vh; position: relative; border-top: 1px solid var(--line); }
.modes-pin { position: sticky; top: var(--head-h); height: calc(100dvh - var(--head-h)); display: flex; align-items: center; overflow: hidden; }
.modes-inner { width: 100%; }
.modes-inner .sec-head { margin-bottom: clamp(16px, 3vw, 36px); }
.modes-grid { align-items: center; row-gap: 20px; }
.modes-left { grid-column: 1 / span 5; }
.modes-right { grid-column: 7 / span 6; position: relative; height: min(520px, 62dvh); }
.mode-name { font: 900 clamp(4rem, 8.6vw, 9rem)/0.86 var(--display); text-transform: uppercase; letter-spacing: 0.005em; color: var(--bone); margin-bottom: 12px; min-height: 0.9em; }
.mode-keys { color: var(--accent); margin-bottom: 12px; }
.mode-desc { min-height: 7.5em; max-width: 44ch; }
.mode-rail { list-style: none; margin: 18px 0 0; padding: 0; display: flex; border-top: 1px solid var(--line-2); }
.mode-rail li { flex: 1; }
.mode-rail button { width: 100%; text-align: left; background: none; border: 0; border-top: 2px solid transparent; margin-top: -1px; padding: 12px 8px 0 0; color: var(--bone-3); font: 500 0.75rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; transition: color 0.25s, border-color 0.25s; }
.mode-rail button .num { display: block; margin-bottom: 4px; }
.mode-rail button:hover { color: var(--bone); }
.mode-rail button[aria-current] { color: var(--bone); border-top-color: var(--accent); }
.mode-count { color: var(--bone-2); }

.scene { position: absolute; inset: 0; opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity 0.5s var(--ease), transform 0.6s var(--ease); }
.scene.on { opacity: 1; transform: none; pointer-events: auto; }
.mini { height: 100%; display: flex; flex-direction: column; border: 1px solid var(--line-2); background: var(--ink-2); font: 400 0.82rem/1.6 var(--mono); color: var(--bone-2); overflow: hidden; }
.mini-bar { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--line); color: var(--bone); font-size: 0.75rem; letter-spacing: 0.04em; }
.mini-code { margin: 0; padding: 14px 0; font: inherit; white-space: pre-wrap; overflow: hidden; }
.mini-code .ml { display: block; padding: 0 14px; border-left: 2px solid transparent; transition: background 0.3s; }
.mini-code .msel.on { background: var(--accent-dim); border-left-color: var(--accent); color: var(--bone); }
.mini [data-m0]:not(.msel) { opacity: 0; transition: opacity 0.3s ease; }
.mini [data-m0].on { opacity: 1; }
.mini-chat { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); display: grid; gap: 8px; min-height: 0; }
.mini-chat p { margin: 0; }
.mini-chat .mq { color: var(--bone); border-left: 2px solid var(--bone-3); padding-left: 10px; min-height: 1.6em; }
.mini-chat .ma { border-left: 2px solid var(--accent); padding-left: 10px; min-height: 5em; }
.mini-log { list-style: none; margin: 0; padding: 14px; display: grid; gap: 8px; }
.mini-log li { padding: 8px 10px; border: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mini-log b { color: var(--accent); font-weight: 600; letter-spacing: 0.06em; min-width: 7ch; }
.mini-log em { font-style: normal; color: var(--bone-3); margin-left: auto; }
.mini-log .ask { border: 1px dashed var(--accent); color: var(--bone); }
.mini-log .ask .ask-b { margin-left: auto; }
.mini .denied { background: var(--bone); color: var(--ink); border-color: var(--bone); }
.mini-halt { margin: auto 14px 14px; padding: 10px 12px; border: 1px solid var(--accent); color: var(--bone); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.halt-oct { width: 16px; height: 16px; background: var(--accent); clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); flex: none; }
.mini-tasks { list-style: none; margin: 0; padding: 14px; display: grid; gap: 8px; }
.mini-tasks li { padding: 10px 12px; border: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.mini-tasks em { margin-left: auto; font-style: normal; color: var(--bone-3); }
.cb { width: 15px; height: 15px; border: 1px solid var(--bone-3); flex: none; position: relative; transition: background 0.25s, border-color 0.25s; }
.cb.checked { background: var(--accent); border-color: var(--accent); }
.cb.checked::after { content: ''; position: absolute; left: 4px; top: 0; width: 4px; height: 9px; border: solid var(--ink); border-width: 0 2px 2px 0; transform: rotate(40deg); }
.mini-btns { display: flex; gap: 10px; padding: 0 14px 14px; margin-top: auto; }
.mbtn { padding: 9px 16px; border: 1px solid var(--line-2); font-weight: 600; font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; }
.mbtn-main { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.mini-foot { padding: 0 14px 14px; margin: 0; }
.mini-diff { margin: 0 14px; border: 1px solid var(--line-2); padding: 6px 0; }
.mini-diff .dl { display: flex; gap: 10px; padding: 0 10px; white-space: pre; background: rgba(236, 228, 210, 0.08); border-left: 2px solid var(--bone); color: var(--bone); }
.mini-diff .dl code { background: none; padding: 0; font-size: inherit; }
.mini-diff .dn { color: var(--bone); }
.mprompt { background: var(--ink-3); border-left: 2px solid var(--accent) !important; color: var(--bone); }

.modes-wrap.static { height: auto; }
.modes-wrap.static .modes-pin { position: static; height: auto; padding-block: 56px; }
.modes-wrap.static .modes-right { height: auto; display: grid; gap: 24px; }
.modes-wrap.static .scene { position: relative; opacity: 1; transform: none; height: 360px; }
.modes-wrap.static .mode-rail { display: none; }
.modes-wrap.static .mini [data-m0] { opacity: 1; }

@media (max-width: 960px) {
  .modes-wrap { height: 440vh; }
  .modes-left, .modes-right { grid-column: 1 / -1; }
  .mode-name { font-size: 4.6rem; margin-bottom: 6px; }
  .mode-desc { min-height: 0; font-size: 1rem; margin-bottom: 0; }
  .mode-rail { margin-top: 10px; }
  .mode-rail button .num { display: none; }
  .mode-rail button { padding-top: 8px; font-size: 0.7rem; }
  .modes-right { height: min(330px, 40dvh); }
  .mini { font-size: 0.72rem; }
  .mini-chat .ma { min-height: 4em; }
  .mini-log, .mini-tasks { padding: 10px; gap: 6px; }
  .modes-wrap.static .scene { height: 340px; }
}

/* ---------- rules ---------- */
.rules .grid { row-gap: 32px; align-items: start; }
.rules-h { grid-column: 1 / span 5; font-size: clamp(2.6rem, 5.4vw, 5rem); position: sticky; top: calc(var(--head-h) + 32px); }
.rules-list { grid-column: 7 / span 6; margin: 0; }
.rules-list > div { display: grid; grid-template-columns: 11ch 1fr; gap: 20px; padding: 22px 0; border-top: 1px solid var(--line); }
.rules-list > div:last-child { border-bottom: 1px solid var(--line); }
.rules-list dt { font: 600 0.78rem var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); padding-top: 4px; }
.rules-list dd { margin: 0; color: var(--bone-2); max-width: 56ch; }
.rules-list dd strong { color: var(--bone); }
@media (max-width: 960px) { .rules-h, .rules-list { grid-column: 1 / -1; position: static; } .rules-list > div { grid-template-columns: 1fr; gap: 6px; } }

/* ---------- backends ---------- */
.back-grid { row-gap: 32px; align-items: start; }
.back-a { grid-column: 1 / span 5; }
.back-a h2 { font-size: clamp(2.6rem, 5vw, 4.6rem); }
.back-list { grid-column: 7 / span 6; list-style: none; margin: 0; padding: 0; counter-reset: b; }
.back-list li { display: grid; grid-template-columns: 4.2rem 1fr; gap: 16px; padding: 24px 0; border-top: 1px solid var(--line); }
.back-list li:last-child { border-bottom: 1px solid var(--line); }
.back-list .num { font: 900 3.6rem/0.9 var(--display); color: transparent; -webkit-text-stroke: 1px var(--accent); }
.back-list h3 { margin-bottom: 6px; font-size: 1.7rem; }
.back-list p { margin: 0; color: var(--bone-2); max-width: 52ch; }
.back-list strong { color: var(--bone); }
@media (max-width: 960px) { .back-a, .back-list { grid-column: 1 / -1; } }

/* ---------- final ---------- */
.final { padding-bottom: 0; }
.final-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 32px; padding-top: clamp(32px, 5vw, 64px); border-top: 1px solid var(--line-2); }
.final h2 { font-size: clamp(3.4rem, 9vw, 9rem); line-height: 0.86; margin: 0; }
.final-cta { display: flex; flex-wrap: wrap; gap: 14px; }
