@font-face { font-family: "Inter"; src: url("../vendor/fonts/inter-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: block; }
@font-face { font-family: "JetBrains Mono"; src: url("../vendor/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); font-weight: 100 800; font-style: normal; font-display: block; }

:root {
  --bg: #0b0f17; --surface: #131a26; --surface-2: #1a2332; --ink: #e6edf7; --muted: #8b98ab; --rule: #26324a;
  --read: #4c9aff; --write: #ff8a3d; --agent: #a78bfa; --link: #5b6576;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --reserve: 0px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--read); outline-offset: 2px; }

#stage { position: fixed; inset: 0; }
#stage canvas { position: absolute; inset: 0; display: block; }
.labels { position: absolute !important; inset: 0; pointer-events: none; }

/* labels in the scene */
.lbl { white-space: nowrap; pointer-events: none; }
.lbl.folder { font: 500 var(--tree-font, 22px)/1 var(--mono); color: var(--muted); padding: 4px 6px; margin-left: -6px; border-radius: 6px; pointer-events: auto; cursor: pointer; transition: color .4s, opacity .4s; }
.lbl.folder .n { font-size: .72em; color: #5b6576; margin-left: 10px; }
.lbl.folder:hover { background: #1a2332cc; }
.lbl.folder.on { color: var(--ink); }
.lbl.folder.read { color: #8dbfff; }
.lbl.strip { font: 500 18px/1 var(--sans); color: var(--muted); }
.lbl.folder.dim { opacity: .5; }
.lbl.agent { font: 600 22px/1.25 var(--sans); color: var(--agent); white-space: nowrap; width: max-content; text-align: center; text-shadow: 0 1px 8px var(--bg), 0 0 2px var(--bg); transition: opacity .4s; }
.lbl.agent.dim { opacity: .35; }
.lbl.callout { font: 600 22px/1.2 var(--sans); padding: 6px 10px; border-radius: 8px; background: #0b0f17e6; border: 1.5px solid var(--muted); color: var(--ink); max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
.lbl.callout.tier-read { border-color: var(--read); }
.lbl.callout.tier-direct { border-color: var(--write); }
.lbl.callout.tier-agent { border-color: var(--agent); }
.lbl.callout.t-file { font: 500 18px/1.2 var(--mono); max-width: 300px; }

/* top bar */
#bar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 16px; padding: 14px 20px; background: linear-gradient(#0b0f17f2 60%, #0b0f1700); z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand h1 { font-size: 18px; font-weight: 650; margin: 0; letter-spacing: -0.01em; white-space: nowrap; }
#presets { display: flex; gap: 5px; flex: 1; justify-content: center; }
.preset, .tools button, #scene-select { background: var(--surface); border: 1px solid var(--rule); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 550; color: var(--muted); cursor: pointer; }
.preset:hover, .tools button:hover { color: var(--ink); border-color: #3a4a63; }
.preset[aria-pressed="true"], #one-action.on, .tools button[aria-pressed="true"] { color: var(--ink); background: #22304a; border-color: #4c6590; }
.preset.story { border-style: dashed; }
#one-action { max-width: 190px; }
#scene-select { border-radius: 8px; padding: 6px 8px; max-width: 200px; }
.tools { display: flex; gap: 6px; align-items: center; }
.search { position: relative; }
#search { width: 180px; background: var(--surface); border: 1px solid var(--rule); border-radius: 999px; padding: 7px 12px; font-size: 14px; }
#search-results { position: absolute; top: calc(100% + 6px); right: 0; width: 380px; max-height: 60vh; overflow: auto; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; box-shadow: 0 12px 40px #0008; }
#search-results li { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
#search-results li b { font-weight: 550; font-size: 15px; }
#search-results li small { font: 12px var(--mono); color: var(--muted); }
#search-results li:hover, #search-results li.at { background: var(--surface-2); }
#search-results li.none { color: var(--muted); cursor: default; }

/* legend */
#legend { position: fixed; left: 24px; bottom: calc(24px + var(--reserve)); margin: 0; font-size: 15px; color: var(--muted); z-index: 3; pointer-events: none; }
#legend p { margin: 4px 0; display: flex; align-items: center; max-width: 300px; }
#legend .faint-note { display: none; }
#legend.faint .faint-note { display: flex; }
.sw { display: inline-block; width: 22px; height: 4px; border-radius: 2px; margin-right: 10px; flex: none; background: var(--muted); }
.sw.k-read { background: var(--read); }
.sw.k-write, .sw.k-agentWrite { background: var(--write); }
.sw.k-agent, .sw.k-starts, .sw.k-agentRead { background: var(--agent); }
.sw.k-link { background: #7b879b; }
.sw.faint { background: linear-gradient(90deg, #4c9aff66, #ff8a3d66); }

/* caption */
#caption { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + var(--reserve)); width: min(1180px, calc(100vw - 48px)); padding: 18px 26px 18px; background: #0f1520ee; border: 1px solid var(--rule); border-radius: 18px; z-index: 4; }
.cap-top { display: flex; align-items: center; gap: 14px; font-size: 16px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
#cap-dots { display: flex; gap: 6px; }
#cap-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--rule); }
#cap-dots i.past { background: #4c6590; }
#cap-dots i.on { background: var(--ink); }
#cap-title { font-size: 38px; line-height: 1.12; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 0; padding-right: 300px; }
#cap-text { font-size: 26px; line-height: 1.3; margin: 6px 0 0; color: #c9d3e1; padding-right: 300px; }
#cap-facts { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 12px 0 0; font-size: 24px; font-weight: 550; }
.fact { display: inline-flex; align-items: center; }
.fact.k-read { color: #8dbfff; }
.fact.k-write, .fact.k-agentWrite { color: #ffb27f; }
.fact.k-starts, .fact.k-agentRead { color: #c6b3ff; }
.fact.k-link { color: #aab4c4; }
.fact.none { color: var(--muted); }
.more { font: 550 18px var(--sans); color: var(--muted); background: var(--surface-2); border: 1px solid var(--rule); border-radius: 999px; padding: 4px 12px; cursor: pointer; align-self: center; }
.more:hover { color: var(--ink); border-color: #4c6590; }
body.embed .more { display: none; }
.cap-nav { position: absolute; right: 22px; top: 18px; display: flex; gap: 8px; }
.cap-nav button { background: var(--surface-2); border: 1px solid var(--rule); border-radius: 12px; padding: 10px 16px; font-size: 18px; font-weight: 600; cursor: pointer; }
.cap-nav button:hover { border-color: #4c6590; }
#caption[data-mode="explore"] #cap-title { font-size: 28px; }

/* detail panel */
#panel { position: fixed; top: 76px; right: 16px; bottom: calc(16px + var(--reserve)); width: 460px; background: #0f1520f5; border: 1px solid var(--rule); border-radius: 16px; z-index: 6; display: flex; flex-direction: column; box-shadow: 0 20px 60px #0009; }
#panel-close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--rule); font-size: 22px; line-height: 1; cursor: pointer; }
#panel-body { overflow: auto; padding: 20px 22px 24px; }
#panel header { padding-right: 36px; }
#panel .kicker { margin: 0; font-size: 13px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
#panel h2 { font-size: 24px; line-height: 1.2; margin: 6px 0 4px; outline: none; overflow-wrap: anywhere; }
#panel .path { font: 13px/1.4 var(--mono); color: var(--muted); margin: 0; overflow-wrap: anywhere; }
#panel section { margin-top: 18px; }
#panel h3 { display: flex; align-items: center; font-size: 13px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
#panel h3 .cnt { margin-left: 8px; color: #5b6576; }
#panel p { margin: 0; font-size: 15px; line-height: 1.45; }
#panel .mono, #panel .kv dd { font-family: var(--mono); font-size: 13px; }
#panel .note { font-size: 14px; color: #ffb27f; margin-top: 14px; }
#panel .none { color: var(--muted); font-size: 14px; margin-top: 14px; }
#panel ul { list-style: none; margin: 0; padding: 0; }
#panel .grp li, #panel .plain li { position: relative; padding: 6px 30px 6px 0; border-top: 1px solid #1c2638; }
#panel .kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 14px; }
#panel .kv dt { color: var(--muted); }
#panel .kv dd { margin: 0; overflow-wrap: anywhere; }
#panel .ref { display: block; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; font-size: 15px; font-weight: 550; color: var(--ink); overflow-wrap: anywhere; }
#panel .ref small { display: block; font: 12px var(--mono); color: var(--muted); font-weight: 400; }
#panel .ref:hover { color: #fff; text-decoration: underline; text-decoration-color: #4c6590; }
#panel .ends .ref { margin-bottom: 10px; }
#panel .line { position: absolute; right: 0; top: 10px; width: 22px; height: 12px; border: 0; padding: 0; border-radius: 4px; cursor: pointer; background: transparent; }
#panel .line::after { content: ""; position: absolute; left: 2px; right: 2px; top: 4px; height: 4px; border-radius: 2px; background: var(--muted); }
#panel .line.k-read::after { background: var(--read); }
#panel .line.k-write::after, #panel .line.k-agentWrite::after { background: var(--write); }
#panel .line.k-starts::after, #panel .line.k-agentRead::after { background: var(--agent); }
#panel .line.k-link::after { background: #7b879b; }
#panel .meta { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 3px; font: 12px/1.4 var(--mono); color: var(--muted); }
#panel .meta.big { font-size: 14px; }
#panel .chg b { color: #ffb27f; font-weight: 600; }
#panel .ev { color: #c9a86a; }
#panel .prompt { white-space: pre-wrap; font: 13px/1.5 var(--mono); background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 10px 12px; margin: 0; max-height: 280px; overflow: auto; }
#panel .stats li { display: flex; align-items: center; font-size: 15px; padding: 3px 0; }

#tip { position: fixed; z-index: 8; pointer-events: none; background: #0b0f17f2; border: 1px solid var(--rule); border-radius: 10px; padding: 8px 12px; max-width: 480px; display: flex; flex-direction: column; gap: 2px; }
#tip b { font-size: 16px; font-weight: 600; }
#tip small { font: 13px var(--mono); color: var(--muted); overflow-wrap: anywhere; }
#fps { position: fixed; right: 12px; bottom: 12px; z-index: 9; font: 13px var(--mono); color: var(--muted); background: #0b0f17cc; padding: 4px 8px; border-radius: 6px; }

/* on a slide: no chrome but the story, with the deck's caption row kept free */
body.embed #bar, body.embed #panel, body.embed .cap-nav { display: none !important; }
body.embed #legend { top: 20px; bottom: auto; left: auto; right: 28px; display: flex; gap: 22px; font-size: 18px; }
body.embed #legend p { max-width: none; white-space: nowrap; }
body.embed #legend p:nth-child(3) { font-size: 0; }
body.embed #legend p:nth-child(3)::after { content: "agent"; font-size: 18px; }
body.embed #cap-title, body.embed #cap-text { padding-right: 0; }

@media (max-width: 1500px) {
  #presets { flex-wrap: wrap; }
  .brand h1 { display: none; }
}
@media (max-width: 1100px) {
  .brand h1 { font-size: 16px; }
  #search { width: 160px; }
  #cap-title { font-size: 26px; padding-right: 0; }
  #cap-text { font-size: 18px; padding-right: 0; }
  #cap-facts { font-size: 16px; }
  .cap-nav { position: static; margin-top: 10px; }
  #panel { width: calc(100vw - 32px); top: auto; height: 55vh; }
  #legend { display: none; }
}
#panel .note.quiet { color: #c9d3e1; background: var(--surface); border-radius: 8px; padding: 8px 10px; }
#panel img.step { width: 100%; border-radius: 8px; border: 1px solid var(--rule); }

/* the caption makes room for the detail panel */
body.panel-open #caption { left: 350px; transform: none; width: calc(100vw - 350px - 492px); }

/* a few lines at a time: what the current frame shows, above the totals */
#cap-now { display: flex; align-items: center; gap: 12px; margin: 12px 0 0; font-size: 26px; line-height: 1.25; font-weight: 600; }
#cap-now .now-dot { flex: none; width: 11px; height: 11px; border-radius: 50%; background: currentColor; animation: now-pulse 1.6s ease-in-out infinite; }
#cap-now-count { margin-left: auto; padding-left: 16px; font-size: 15px; font-weight: 500; color: var(--muted); white-space: nowrap; }
#cap-now.k-read { color: #8dbfff; }
#cap-now.k-write { color: #ffb27f; }
#cap-now.k-starts { color: #c6b3ff; }
#cap-now.k-link { color: #c3cbd8; }
#caption.spot #cap-facts { font-size: 18px; font-weight: 500; margin-top: 8px; }
#caption.spot #cap-facts .fact { opacity: .8; }
#caption.spot .more { font-size: 15px; }
@keyframes now-pulse { 50% { opacity: .35; } }
#cap-play { min-width: 104px; }
#cap-play[aria-pressed="true"] { border-color: #4c6590; background: #22304a; }
@media (prefers-reduced-motion: reduce) { #cap-now .now-dot { animation: none; } }
@media (max-width: 1100px) { #cap-now { font-size: 18px; } }
