/* The Observatory (E178): the brain as a night sky, lit by what the agent touches.
   One bold thing — the comets crossing the sky. Everything around it is quiet instrument glass. */
:root {
  --sky-0: #060a18;
  --sky-1: #0c1430;
  --haze: rgba(98, 76, 168, 0.22);
  --ink: #e6ecff;
  --ink-2: #aab5d6;
  --ink-3: #6f7ba0;
  --glass: rgba(14, 21, 46, 0.66);
  --rule: rgba(173, 190, 255, 0.12);
  --read: #38bdf8;
  --search: #fbbf24;
  --edit: #f472b6;
  --run: #a78bfa;
  --yad: #34d399;
  --warn: #fb7185;
  --sans: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(1200px 700px at 72% 18%, var(--haze), transparent 60%),
    radial-gradient(900px 600px at 10% 90%, rgba(20, 90, 140, 0.18), transparent 60%),
    linear-gradient(180deg, var(--sky-1), var(--sky-0) 70%);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.bar, .deck, .river { position: relative; z-index: 1; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--read); outline-offset: 2px; }
.quiet { color: var(--ink-3); margin: 0; }
.small { font-size: 13px; }

/* ---- the top bar ---- */
.bar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--rule);
}
.mark { display: flex; align-items: center; gap: 10px; min-width: 120px; }
.pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--ink-3);
  box-shadow: 0 0 0 0 transparent;
}
.pulse.is-live { background: var(--yad); animation: breathe 2.4s ease-in-out infinite; }
.pulse.is-idle { background: var(--ink-3); }
.pulse.is-replay { background: var(--search); }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  50% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
}
.mode { font-weight: 600; letter-spacing: 0.01em; }
.where { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex: 1; }
.where-story { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.where-task { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.limit {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  padding: 5px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  white-space: nowrap;
}

/* ---- the deck: Now | sky | Plan ---- */
.deck {
  min-height: 0;
  display: grid;
  grid-template-columns: 300px 1fr 330px;
}
.now, .plan {
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow-y: auto;
  padding: 22px 22px 18px;
}
.now { border-right: 1px solid var(--rule); }
.plan { border-left: 1px solid var(--rule); }

.now-op { font-size: 28px; font-weight: 600; line-height: 1.1; color: var(--ink); transition: color 0.4s; }
.now-path.is-quiet { font-family: var(--sans); color: var(--ink-2); }
.now-path {
  margin-top: 8px;
  font: 500 15px/1.4 var(--mono);
  color: var(--ink);
  overflow-wrap: anywhere;
  min-height: 2.8em;
}
.now-when { margin-top: 6px; color: var(--ink-3); font-size: 13px; min-height: 1.2em; }
.tally { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 14px; }
.tally li { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: baseline; }
.tally-n { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tally-l { color: var(--ink-2); }
.tally .spark { grid-column: 1 / -1; width: 100%; height: 26px; margin-top: 4px; }
.tally li[data-op="read"] .tally-n { color: var(--read); }
.tally li[data-op="search"] .tally-n { color: var(--search); }
.tally li[data-op="edit"] .tally-n { color: var(--edit); }
.tally li[data-op="run"] .tally-n { color: var(--run); }
.sessions { margin-top: 24px; display: grid; gap: 6px; }
.sessions label { color: var(--ink-2); font-size: 13px; }
select {
  width: 100%; max-width: 100%;
  background: rgba(6, 10, 24, 0.7); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 8px; padding: 7px 9px; font: inherit;
}

/* ---- the sky ---- */
.sky { position: relative; min-width: 0; min-height: 0; }
.graph, .fx { position: absolute; inset: 0; width: 100%; height: 100%; }
.fx { pointer-events: none; }
.sky-tools { position: absolute; right: 16px; top: 14px; display: flex; gap: 6px; }
.tool {
  background: rgba(10, 16, 36, 0.72);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 6px 11px;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13px;
}
.tool:hover { color: var(--ink); border-color: rgba(173, 190, 255, 0.3); }
.tool[aria-pressed="true"] { color: var(--ink); border-color: rgba(56, 189, 248, 0.55); background: rgba(56, 189, 248, 0.12); }
.tool-live.is-on { color: #052e1f; background: var(--yad); border-color: var(--yad); }
.toast {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  margin: 0; padding: 8px 14px; border-radius: 10px;
  background: rgba(10, 16, 36, 0.9); border: 1px solid var(--rule); color: var(--ink-2); font-size: 13px;
}
.empty {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  display: grid; grid-template-columns: auto 1fr; column-gap: 18px; align-items: center;
  padding: 18px 22px; border-radius: 16px;
  background: rgba(10, 16, 36, 0.78); border: 1px solid var(--rule);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
}
.empty .empty-ring { grid-row: 1 / span 2; }
.empty-ring {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 0 40px rgba(56, 189, 248, 0.25), inset 0 0 30px rgba(56, 189, 248, 0.15);
  animation: ring 3.2s ease-in-out infinite;
}
@keyframes ring { 0%, 100% { transform: scale(0.92); opacity: 0.6; } 50% { transform: scale(1.04); opacity: 1; } }
.empty-title { margin: 0; font-size: 17px; font-weight: 600; }
.empty-hint { margin: 0; max-width: 44ch; color: var(--ink-2); }
.empty-hint code { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.inspect {
  position: absolute; z-index: 3; max-width: 320px;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(10, 16, 36, 0.94); border: 1px solid var(--rule);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-size: 13px; color: var(--ink-2);
}
.inspect strong { display: block; color: var(--ink); font-size: 15px; overflow-wrap: anywhere; }
.inspect .ipath { font-family: var(--mono); overflow-wrap: anywhere; margin-top: 2px; }
.inspect .icounts { display: flex; gap: 12px; margin-top: 8px; }

/* ---- plan and reality ---- */
.plan-h { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.plan h3 { margin: 22px 0 6px; font-size: 14px; font-weight: 600; color: var(--ink); }
.plan-task .story { color: var(--ink-2); font-size: 13px; margin: 0; }
.plan-task .task { font-size: 16px; font-weight: 600; margin: 2px 0 10px; overflow-wrap: anywhere; }
.meter { height: 6px; border-radius: 3px; background: rgba(173, 190, 255, 0.12); overflow: hidden; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--edit), #f9a8d4); border-radius: 3px; transition: width 0.5s ease; }
.meter-l { margin: 6px 0 10px; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.files, .paths { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.files li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: baseline; font: 13px/1.45 var(--mono); overflow-wrap: anywhere; }
.files .st { font-family: var(--sans); text-align: center; }
.files .is-edit .st { color: var(--edit); }
.files .is-read .st { color: var(--read); }
.files .is-none { color: var(--ink-3); }
.paths li { font: 13px/1.45 var(--mono); color: var(--ink-2); overflow-wrap: anywhere; }
.plan-out h3 { color: var(--warn); }
.plan-out .paths li { color: #fecdd3; }
.plan-touched h3 span { font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
details .paths { margin-top: 6px; }
.note { margin: 18px 0 0; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(251, 191, 36, 0.35); color: #fde68a; font-size: 13px; }

/* ---- the river ---- */
.river {
  border-top: 1px solid var(--rule);
  background: rgba(6, 10, 24, 0.82);
  padding: 10px 22px 12px;
}
.river-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.speeds, .spans { display: flex; gap: 4px; }
.spans { margin-left: auto; }
.river-wrap { position: relative; }
.river-canvas { display: block; width: 100%; height: 76px; cursor: ew-resize; border-radius: 8px; }
.river-tip {
  position: absolute; bottom: 84px; transform: translateX(-50%);
  padding: 6px 10px; border-radius: 8px; white-space: nowrap;
  background: rgba(10, 16, 36, 0.95); border: 1px solid var(--rule);
  font-size: 12px; color: var(--ink-2); pointer-events: none;
}
.river-tip b { color: var(--ink); font-weight: 600; }
.river-ends { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 12px; margin-top: 4px; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  body { overflow: auto; }
  .deck { grid-template-columns: 1fr; grid-template-rows: 58vh auto auto; }
  .sky { order: 1; }
  .now { order: 2; border-right: 0; border-top: 1px solid var(--rule); }
  .plan { order: 3; border-left: 0; border-top: 1px solid var(--rule); }
  .limit { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse.is-live, .empty-ring { animation: none; }
  .meter > span, .now-op { transition: none; }
}
