/* ============================================================
   TVS // AGENT — a machine-first knowledge object
   Clean neon. Answer-first. 4D corpus that morphs (FLIP).
   ============================================================ */
:root {
  --h1: 196; --h2: 292;
  --font-head: 'Chakra Petch', sans-serif;
  --font-body: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg:    oklch(0.16 0.03 270);
  --bg-2:  oklch(0.135 0.028 272);
  --panel: oklch(0.185 0.03 270);
  --ink:   oklch(0.97 0.012 250);
  --muted: oklch(0.72 0.03 268);
  --faint: oklch(0.56 0.028 268);
  --line:  oklch(1 0 0 / 0.09);
  --line-2:oklch(1 0 0 / 0.05);
  --c1: oklch(0.83 0.15 var(--h1));
  --c2: oklch(0.70 0.20 var(--h2));
  --c1-dim: oklch(0.83 0.15 var(--h1) / 0.14);
  --grad: linear-gradient(110deg, var(--c1), var(--c2));
  --ok: oklch(0.80 0.17 150);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
::selection { background: oklch(0.83 0.15 var(--h1) / 0.3); color: #fff; }
h1,h2,h3,h4 { margin: 0; font-family: var(--font-head); font-weight: 600; line-height: 1.12; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
.mono { font-family: var(--font-mono); }

/* one restrained ambient glow, no noise */
.amb {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(45% 40% at 78% -6%, oklch(0.70 0.20 var(--h2) / 0.22), transparent 70%),
    radial-gradient(40% 36% at 10% 104%, oklch(0.83 0.15 var(--h1) / 0.16), transparent 72%);
  transform: translate3d(calc(var(--px,0) * -14px), calc(var(--py,0) * -14px), 0);
}

/* ============ app grid ============ */
.app {
  position: relative; z-index: 1; height: 100vh; height: 100dvh;
  display: grid;
  grid-template-columns: 264px minmax(0,1fr) 360px;
  grid-template-rows: 60px minmax(0,1fr);
  grid-template-areas: "top top top" "rail stage machine";
  transition: grid-template-columns .6s cubic-bezier(.45,.05,.2,1);
}
.app.agent { grid-template-columns: 0px minmax(0,1fr) 620px; }

/* ============ topbar ============ */
.top { grid-area: top; display: flex; align-items: center; gap: 18px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand .mk { width: 30px; height: 30px; border-radius: 9px; background: var(--grad); color: #04121a; display: grid; place-items: center; font-weight: 700; font-size: 12px; font-family: var(--font-mono); }
.brand .bt { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.02em; }
.brand .bt b { font-weight: 700; }
.brand .bt span { color: var(--faint); }
.top .obj { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--faint); padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; }
.top .sp { flex: 1; }
.top .sess { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.top .sess b { color: var(--c1); }
.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; font-family: var(--font-mono); font-size: 12px; }
.lang-switch button { border: 0; background: transparent; color: var(--muted); padding: 6px 11px; }
.lang-switch button.active { background: var(--grad); color: #04121a; font-weight: 700; }
.tbtn {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  transition: border-color .2s, color .2s, background .2s;
}
.tbtn:hover { border-color: var(--c1); color: var(--c1); background: var(--c1-dim); }
.tbtn .d { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.tbtn.on { border-color: var(--c1); color: var(--c1); background: var(--c1-dim); }
.tbtn.on .d { background: var(--c1); box-shadow: 0 0 8px var(--c1); }

/* ============ left rail: intents (the queries) ============ */
.rail { grid-area: rail; border-right: 1px solid var(--line); padding: 22px 16px; overflow: hidden; display: flex; flex-direction: column; gap: 4px; transition: opacity .4s, padding .4s; }
.app.agent .rail { opacity: 0; pointer-events: none; padding: 0; }
.rail-h { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--faint); padding: 0 10px 12px; }
.intent {
  position: relative; text-align: left; background: transparent; border: 1px solid transparent;
  border-radius: 11px; padding: 12px 13px; color: var(--muted); display: grid; gap: 3px;
  transition: background .2s, border-color .2s, color .2s;
}
.intent .q { font-family: var(--font-head); font-weight: 600; font-size: 14.5px; color: var(--ink); letter-spacing: 0.01em; }
.intent .qid { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; color: var(--faint); }
.intent:hover { background: oklch(1 0 0 / 0.03); border-color: var(--line); }
.intent.active { background: var(--c1-dim); border-color: oklch(0.83 0.15 var(--h1) / 0.4); }
.intent.active .q { color: var(--c1); }
.intent .tick { position: absolute; right: 11px; top: 13px; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); opacity: 0; }
.intent.seen .tick { opacity: 1; background: var(--c1); box-shadow: 0 0 6px oklch(0.83 0.15 var(--h1) / 0.7); }

/* ============ center stage ============ */
.stage { grid-area: stage; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.answer {
  padding: 28px 34px 22px; border-bottom: 1px solid var(--line); flex-shrink: 0;
  perspective: 1000px;
}
.answer .qline { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--c1); margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.answer .qline .qp { opacity: 0.8; }
.answer .qline .qp::before { content: "▸ "; }
.answer .aq { font-family: var(--font-mono); font-size: 13px; color: var(--muted); margin-bottom: 14px; letter-spacing: 0.01em; }
.answer .aq::before { content: "» "; color: var(--c1); }
.answer .qline .score { color: var(--faint); }
.answer .qline .score b { color: var(--ok); }
.answer .atext { font-family: var(--font-head); font-weight: 500; font-size: clamp(20px, 2.5vw, 30px); line-height: 1.32; letter-spacing: -0.01em; max-width: 30ch; }
.answer .atext em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.answer .ameta { margin-top: 14px; font-family: var(--font-mono); font-size: 11px; color: var(--faint); display: flex; gap: 16px; flex-wrap: wrap; }
.answer .ameta b { color: var(--muted); }

.corpus-h { display: flex; align-items: center; gap: 12px; padding: 16px 34px 4px; flex-shrink: 0; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--faint); }
.corpus-h .ln { flex: 1; height: 1px; background: var(--line); }

/* the morphing corpus */
.corpus-wrap { flex: 1; overflow: hidden; padding: 8px 34px 30px; }
.corpus {
  display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: 58px; gap: 11px;
  grid-auto-flow: dense;
}
.block {
  position: relative; grid-column: span 2; grid-row: span 1;
  border: 1px solid var(--line); border-radius: 13px; background: oklch(1 0 0 / 0.025);
  padding: 12px 14px; overflow: hidden; will-change: transform;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .3s, background .3s, opacity .45s, filter .45s;
}
.block .b-id { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; color: var(--faint); display: flex; align-items: center; gap: 7px; }
.block .b-id::before { content: ""; width: 5px; height: 5px; border-radius: 1px; background: var(--faint); }
.block .b-title { font-family: var(--font-head); font-weight: 600; font-size: 14px; color: var(--ink); line-height: 1.2; }
.block .b-body { color: var(--muted); font-size: 13px; line-height: 1.5; display: none; }
.block .b-body .kv { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line-2); font-family: var(--font-mono); font-size: 12px; }
.block .b-body .kv .k { color: var(--faint); } .block .b-body .kv .v { color: var(--ink); text-align: right; }
.block .b-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.block .b-chips span { font-family: var(--font-mono); font-size: 11px; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; }
.block .b-metrics { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin-top: 4px; }
.block .b-metrics .m { border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.block .b-metrics .m .v { font-family: var(--font-head); font-weight: 700; font-size: 15px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.block .b-metrics .m .k { font-family: var(--font-mono); font-size: 9px; color: var(--faint); margin-top: 2px; }

/* focus state — the evidence the agent surfaced */
.block.focus { grid-column: span 3; grid-row: span 4; background: oklch(1 0 0 / 0.045); border-color: oklch(0.83 0.15 var(--h1) / 0.42); box-shadow: 0 24px 60px -40px oklch(0.83 0.15 var(--h1) / 0.7); }
.block.focus .b-body { display: block; }
.block.focus .b-title { font-size: 17px; }
.block.focus .b-id { color: var(--c1); }
.block.focus .b-id::before { background: var(--c1); box-shadow: 0 0 8px var(--c1); }
.block.focus.tall { grid-row: span 5; }
.block.focus.wide { grid-column: span 4; }
.block.dim { opacity: 0.32; filter: saturate(0.5); }
.block.dim:hover { opacity: 0.7; filter: none; }

/* agent view — flatten to pure structured records */
.app.agent .corpus { grid-template-columns: repeat(3, 1fr); grid-auto-rows: auto; }
.app.agent .block { grid-column: span 1 !important; grid-row: auto !important; background: oklch(0 0 0 / 0.25); border-color: var(--line); opacity: 1 !important; filter: none !important; box-shadow: none; }
.app.agent .block .b-body { display: block; font-family: var(--font-mono); font-size: 11.5px; }
.app.agent .block .b-title { font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; }
.app.agent .corpus-h .lbl::after { content: " — RAW STRUCTURED RECORDS"; }

/* ============ right: machine readout ============ */
.machine { grid-area: machine; border-left: 1px solid var(--line); background: var(--bg-2); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.machine-h { padding: 18px 22px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--c1); }
.machine-h .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: bl 2s infinite; }
@keyframes bl { 0%,100%{opacity:1;} 50%{opacity:.4;} }
.machine-body { padding: 18px 22px; overflow-y: auto; font-family: var(--font-mono); font-size: 12px; line-height: 1.7; color: var(--muted); }
.machine-body::-webkit-scrollbar { width: 7px; } .machine-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 7px; }
.rd { margin-bottom: 18px; }
.rd .rk { color: var(--faint); letter-spacing: 0.08em; }
.rd .rv { color: var(--ink); }
.rd .rv.ok { color: var(--ok); }
.rd .rv.c1 { color: var(--c1); }
.evlist { display: grid; gap: 4px; margin-top: 4px; }
.evlist .ev { color: var(--c1); cursor: pointer; }
.evlist .ev::before { content: "▸ "; color: var(--faint); }
.evlist .ev:hover { text-decoration: underline; }
.ld { background: oklch(0 0 0 / 0.3); border: 1px solid var(--line); border-radius: 11px; padding: 14px; font-size: 11px; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.ld .key { color: var(--c1); } .ld .str { color: var(--ok); } .ld .num { color: var(--c2); }
.machine-foot { padding: 12px 22px; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; color: var(--faint); display: flex; justify-content: space-between; }

/* ============ boot (minimal) ============ */
.boot { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; transition: opacity .5s, visibility .5s; }
.boot.done { opacity: 0; visibility: hidden; }
.boot .bi { font-family: var(--font-mono); font-size: 12px; color: var(--muted); width: min(440px, 84vw); }
.boot .bb { font-family: var(--font-head); font-weight: 700; letter-spacing: 0.34em; color: var(--c1); text-transform: uppercase; margin-bottom: 18px; font-size: 13px; }
.boot .bl { min-height: 84px; } .boot .bl .ok { color: var(--ok); }
.boot .bbar { height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 16px; }
.boot .bbar i { display: block; height: 100%; width: 0; background: var(--grad); }

/* ============ responsive ============ */
@media (max-width: 1080px) {
  .app { grid-template-columns: 220px minmax(0,1fr) 0px; }
  .app.agent { grid-template-columns: 0px minmax(0,1fr) 0px; }
  .machine { display: none; }
  .corpus { grid-template-columns: repeat(4,1fr); }
  .block.focus { grid-column: span 4; }
}
@media (max-width: 720px) {
  .app { grid-template-rows: 56px auto 1fr; grid-template-columns: 1fr; grid-template-areas: "top" "rail" "stage"; }
  .rail { flex-direction: row; overflow-x: auto; gap: 8px; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-h { display: none; } .intent { flex-shrink: 0; }
  .corpus { grid-template-columns: repeat(2,1fr); }
  .block, .block.focus { grid-column: span 2; grid-row: auto; }
  .answer .atext { font-size: 20px; }
  .top .obj, .top .sess { display: none; }
}
