/* One terminal window: the conversation on the left; agents, topic, resolution math and archive on the right.
   A single dark look by choice, with a pale fluorescent accent and one color per lineage. */
:root {
  --page: #0A0F10;
  --term: #0D1416;
  --pane: #10191B;
  --bar: #141E1D;
  --line: #22312F;
  --fg: #D8E1DD;
  --dim: #7E8F8A;
  --faint: #4C5D58;
  --glow: #E9DE8F;
  --closure: #F0B35B;
  --proximity: #6CC8DA;
  --similarity: #AE9EF5;
  --figure: #8ACF84;
  --continuity: #F2806F;
  --ok: #8ACF84;
  --bad: #F2806F;
  --warn: #F0B35B;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Martian Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--fg); font: 15px/1.5 var(--sans); }
[hidden] { display: none !important; }

.wrap {
  max-width: 1280px; margin: 0 auto; display: grid; gap: 18px;
  padding-top: max(28px, env(safe-area-inset-top, 0px));
  padding-bottom: max(40px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
header h1 { margin: 0; font: 600 clamp(1.3rem, 2.8vw, 1.9rem)/1.2 var(--display); letter-spacing: -0.01em; color: var(--glow); }
header p { margin: 8px 0 0; color: var(--dim); max-width: 70ch; line-height: 1.55; text-wrap: pretty; }

.term { border: 1px solid var(--line); border-radius: 10px; background: var(--term); overflow: hidden; box-shadow: 0 24px 70px -36px rgba(0, 0, 0, 0.9); }
.titlebar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--bar); font: 12px/1.4 var(--mono); color: var(--dim); }
.titlebar b { color: var(--fg); font-weight: 500; }
.titlebar-right { display: flex; align-items: center; gap: 10px; }
#viewLabel { color: var(--glow); }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font: 500 10.5px/1.6 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.pill.live { color: var(--glow); border-color: currentColor; }
.pill.live::before { content: "● "; animation: blink 2s steps(2, start) infinite; }
.pill.warn { color: var(--warn); border-color: currentColor; }
@keyframes blink { to { visibility: hidden; } }

button { font: 500 12px/1 var(--mono); color: var(--fg); background: var(--pane); border: 1px solid var(--line); border-radius: 6px; padding: 7px 11px; cursor: pointer; }
button:hover { border-color: var(--dim); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--proximity); outline-offset: 2px; }
button.ghost { background: transparent; color: var(--glow); border-color: currentColor; }

.panes { display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.log {
  height: min(72vh, 720px); min-height: 420px; overflow-y: auto; padding: 14px 16px 10px;
  font: 13px/1.6 var(--mono); scrollbar-color: var(--line) transparent;
  background-image: repeating-linear-gradient(to bottom, rgba(233, 222, 143, 0.016) 0 1px, transparent 1px 3px);
}
.side { height: min(72vh, 720px); min-height: 420px; overflow-y: auto; border-left: 1px solid var(--line); background: var(--pane); padding: 14px 16px 22px; font: 12px/1.5 var(--mono); display: grid; gap: 22px; align-content: start; scrollbar-color: var(--line) transparent; }
@media (max-width: 960px) {
  .panes { grid-template-columns: minmax(0, 1fr); }
  .log { height: 62vh; min-height: 360px; font-size: 12.5px; padding: 12px 12px 8px; }
  .side { height: auto; min-height: 0; border-left: 0; border-top: 1px solid var(--line); }
}

.status { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px; padding: 6px 14px; border-top: 1px solid var(--line); background: var(--bar); font: 11.5px/1.5 var(--mono); color: var(--faint); font-variant-numeric: tabular-nums; }

/* conversation */
.boot { color: var(--dim); margin-bottom: 10px; }
.boot-title { color: var(--glow); font-weight: 600; }
.m { display: grid; grid-template-columns: 8ch 14ch minmax(0, 1fr); gap: 0 1.2ch; padding: 2px 0; }
.m .t { color: var(--faint); font-variant-numeric: tabular-nums; }
.m .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m .tx { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.m .to { color: var(--dim); }
.m.fresh { animation: arrive 0.5s ease-out; }
@keyframes arrive { from { background: rgba(233, 222, 143, 0.06); } to { background: transparent; } }
.m.engine .who { color: var(--glow); }
.m.engine .tx { color: var(--dim); }
.m.engine .why { color: var(--faint); margin-top: 2px; }
.m.spec .who { color: var(--glow); }
.spec-rows { display: grid; grid-template-columns: 13ch minmax(0, 1fr); gap: 1px 1ch; margin-top: 4px; }
.spec-rows .k { color: var(--dim); }
.spec-rows .v { overflow-wrap: anywhere; }
.rule { margin: 16px 0 6px; color: var(--glow); opacity: 0.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.sys { color: var(--faint); padding: 2px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.typing { min-height: 1.6em; color: var(--faint); padding-top: 4px; }
.typing .dots::after { content: ""; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@media (max-width: 600px) {
  .m { grid-template-columns: auto minmax(0, 1fr); }
  .m .t { grid-column: 1; }
  .m .who { grid-column: 2; }
  .m .tx { grid-column: 1 / -1; padding-left: 1ch; }
  .spec-rows { grid-template-columns: minmax(0, 1fr); }
}

.c-closure { color: var(--closure); }
.c-proximity { color: var(--proximity); }
.c-similarity { color: var(--similarity); }
.c-figure { color: var(--figure); }
.c-continuity { color: var(--continuity); }

/* side pane */
.side h2 { margin: 0 0 10px; display: flex; justify-content: space-between; gap: 8px; font: 600 11px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.side h2 span { letter-spacing: 0.02em; text-transform: none; font-weight: 400; color: var(--faint); text-align: right; }
.grid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.cell { aspect-ratio: 1; max-width: 100%; border-radius: 3px; background: currentColor; opacity: 0.18; transition: opacity 0.6s ease; }
.cell.spoke { opacity: 0.5; }
.cell.speak { animation: speak 1.8s ease-out; }
@keyframes speak { 0% { opacity: 1; box-shadow: 0 0 0 3px currentColor; } 100% { box-shadow: 0 0 0 0 transparent; } }
.legend { display: grid; gap: 3px; margin-top: 10px; }
.legend div { display: grid; grid-template-columns: 11ch minmax(0, 1fr); gap: 1ch; }
.legend .d { color: var(--faint); }
.kv { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; }
.kv > span:first-child { color: var(--dim); flex: none; }
.kv .v { text-align: right; overflow-wrap: anywhere; min-width: 0; }
.kv .v.bad { color: var(--bad); }
.kv .v.hl { color: var(--glow); }
.kv .v.ok { color: var(--ok); }
.idea { margin: 8px 0 0; color: var(--fg); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.note { color: var(--faint); font-size: 11px; text-align: right; margin-top: 2px; overflow-wrap: anywhere; }
.big { display: flex; align-items: baseline; gap: 8px; }
.big .num { font: 600 30px/1 var(--display); font-variant-numeric: tabular-nums; }
.big .of { color: var(--dim); }
.state { margin-left: auto; border: 1px solid currentColor; border-radius: 4px; padding: 0 6px; font-size: 11px; color: var(--warn); }
.state.ok { color: var(--ok); }
.meter { position: relative; height: 6px; margin: 10px 0 6px; background: var(--line); border-radius: 3px; }
.meter i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--warn); border-radius: 3px; transition: width 0.6s ease; }
.meter.ok i { background: var(--ok); }
.meter .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--fg); left: 80%; }
.formula { color: var(--faint); font-size: 11px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.dims { display: grid; gap: 8px; margin-top: 14px; }
.drow { display: grid; grid-template-columns: minmax(0, 1fr) 5ch 6ch; gap: 3px 8px; align-items: baseline; font-variant-numeric: tabular-nums; }
.drow.headrow { color: var(--faint); font-size: 10.5px; letter-spacing: 0.04em; }
.drow .n small { color: var(--faint); font-size: 10.5px; margin-left: 5px; }
.drow .c, .drow .g { text-align: right; color: var(--dim); }
.drow .bar { grid-column: 1 / -1; position: relative; height: 4px; background: var(--line); border-radius: 2px; }
.drow .bar i { position: absolute; inset: 0 auto 0 0; width: 0; background: #9DB0AA; border-radius: 2px; transition: width 0.6s ease; }
.drow.weak .n, .drow.weak .g { color: var(--warn); }
.drow.weak .bar i { background: var(--warn); }
.archive { display: grid; gap: 2px; }
.archive button {
  display: grid; grid-template-columns: 6ch 5ch minmax(0, 1fr); gap: 8px; align-items: baseline; text-align: left;
  width: 100%; padding: 5px 6px; border: 1px solid transparent; border-radius: 4px; background: transparent;
  color: var(--dim); font: 12px/1.45 var(--mono); font-variant-numeric: tabular-nums;
}
.archive button:hover { border-color: var(--line); color: var(--fg); }
.archive button[aria-current="true"] { border-color: var(--line); background: var(--term); color: var(--fg); }
.archive .id { color: var(--glow); }
.archive .sc.ok { color: var(--ok); }
.archive .tx { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--faint); font-size: 11.5px; }

.foot { color: var(--dim); font-size: 14px; line-height: 1.6; max-width: 80ch; }
.foot p { margin: 0 0 10px; }
.foot b { color: var(--fg); font-weight: 500; }
.foot a { color: var(--fg); text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .meter i, .drow .bar i, .cell { transition: none; }
  .cell.speak, .m.fresh, .pill.live::before, .typing .dots::after { animation: none; }
}
