:root {
  --bg: #0a0c0f;
  --panel: #0e1115;
  --panel-2: #11151a;
  --line: #232a31;
  --line-soft: #1a2026;
  --text: #d9dfe5;
  --muted: #7d8791;
  --faint: #505a64;
  --accent: #9fb4c8;
  --thinking: #d7c58e;
  --revisited: #a8bed5;
  --escaped: #a8d5ba;
  --superseded: #bd9ca8;
  --sidebar: 330px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
button, input { font: inherit; }
a { color: var(--accent); }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: 42px minmax(0, 1fr) 28px;
}

.topbar {
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--line);
  background: #0b0e11;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px;
  font-size: 12px;
}
.brand-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-row strong { font-weight: 650; letter-spacing: .02em; }
.brand-mark { width: 10px; height: 10px; border: 1px solid var(--accent); box-shadow: 0 0 0 2px rgb(159 180 200 / 6%); }
.path { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-meta { color: var(--faint); white-space: nowrap; }

.sidebar {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.sidebar-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--faint);
  font-size: 11px;
  letter-spacing: .12em;
}
.count { letter-spacing: 0; }
.session-list { padding: 8px; }
.session {
  width: 100%;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 10px;
  gap: 10px;
  padding: 10px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.session:hover { background: #14191e; }
.session.active { background: #171d23; }
.session-time { color: var(--faint); font-size: 11px; padding-top: 2px; }
.session-title { font-size: 12px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.status-dot { width: 7px; height: 7px; margin-top: 4px; border-radius: 999px; background: var(--faint); }
.status-dot.thinking { background: var(--thinking); }
.status-dot.revisited { background: var(--revisited); }
.status-dot.escaped { background: var(--escaped); }
.status-dot.superseded { background: var(--superseded); }

.main {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  overflow: auto;
  background: linear-gradient(to bottom, var(--panel-2), #0f1215);
}
.terminal { width: min(960px, calc(100% - 48px)); margin: 0 auto; padding: 30px 0 90px; }
.session-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.k { color: #66717c; }
.v { color: #8c98a4; overflow-wrap: anywhere; }

.prompt-block {
  margin-top: 26px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  font-size: 13px;
  line-height: 1.55;
}
.prompt-symbol { color: var(--accent); }
.who { margin-bottom: 4px; color: #9eb0bf; font-size: 11px; }
.prompt-copy { white-space: pre-wrap; }

.thinking-line, .still-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.thinking-line { margin: 18px 0 24px 26px; }
.still-thinking { margin: 30px 0 0 26px; padding-top: 18px; border-top: 1px dashed var(--line); }
.spinner { width: 10px; height: 10px; border: 1px solid var(--faint); border-top-color: var(--text); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.mutation { margin-left: auto; color: var(--faint); }

.response { margin-left: 26px; max-width: 800px; color: #cbd2d9; font-size: 14px; line-height: 1.72; }
.response p { margin: 0 0 16px; }
.response h1, .response h2, .response h3 { color: #e5eaef; font-size: 14px; font-weight: 650; }
.response h1 { margin: 34px 0 14px; }
.response h2 { margin: 28px 0 12px; }
.response h3 { margin: 22px 0 10px; }
.response ul, .response ol { margin: 8px 0 18px 20px; padding: 0; }
.response li { margin: 6px 0; }
.response strong { color: #eef2f5; font-weight: 650; }
.response em { color: #dce2e8; }
.response code { padding: 1px 4px; border: 1px solid #1f252b; border-radius: 3px; background: #14191e; color: #b8c7d5; }
.response pre { overflow: auto; margin: 18px 0; padding: 14px; border: 1px solid var(--line); background: #0b0e11; }
.response pre code { padding: 0; border: 0; background: transparent; }
.response blockquote { margin: 18px 0; padding-left: 14px; border-left: 2px solid var(--line); color: #aeb8c2; }
.response hr { margin: 26px 0; border: 0; border-top: 1px solid var(--line); }

.escape-block { margin: 26px 0 0 26px; padding: 12px 14px; border: 1px solid var(--line); background: #0c1112; max-width: 800px; }
.escape-label { margin-bottom: 5px; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.escape-block a { font-size: 12px; text-decoration: none; }
.escape-block a:hover { text-decoration: underline; }

.statusbar {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 10px;
  border-top: 1px solid var(--line);
  background: #090b0d;
  color: var(--faint);
  font-size: 10px;
}
.status-left, .status-right { display: flex; gap: 16px; min-width: 0; }
.statusbar span { white-space: nowrap; }
kbd { padding: 0 4px; border: 1px solid #293039; border-radius: 3px; color: #7f8a94; font: inherit; }

.error { margin: 30px 26px; color: #dca39f; font-size: 13px; line-height: 1.6; }

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; display: block; }
  .topbar { position: sticky; top: 0; z-index: 10; height: 42px; }
  .top-meta, .statusbar { display: none; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 220px; }
  .main { overflow: visible; }
  .terminal { width: min(100% - 28px, 760px); padding: 20px 0 70px; }
}
