:root {
  color-scheme: light;
  --paper: #f7f6f2;
  --surface: #ffffff;
  --ink: #171713;
  --muted: #706f68;
  --line: #dfddd4;
  --line-strong: #cac7bb;
  --accent: #e6ff4f;
  --accent-ink: #202500;
  --user: #24241f;
  --user-ink: #ffffff;
  --danger: #a93a2c;
  --graph-entity: #3973d6;
  --graph-value: #d67a17;
  --graph-memory: #7957c8;
  --graph-edge: #8d8a80;
  --radius: 16px;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button, textarea, select, input { font: inherit; }
button { color: inherit; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: 12px clamp(18px, 3vw, 48px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -.04em;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; line-height: 1.05; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }

.mode-switch {
  position: absolute;
  left: 50%;
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  transform: translateX(-50%);
}

.mode-button {
  min-height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.mode-button:hover { color: var(--ink); }
.mode-button.is-active { background: var(--ink); color: var(--surface); }

.topbar-actions { display: flex; gap: 6px; }

.text-button {
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}

.text-button:hover { border-color: var(--line); background: var(--surface); }

.settings {
  position: sticky;
  z-index: 19;
  top: 72px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px clamp(18px, 3vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.settings[hidden] { display: none; }
.settings label { display: grid; min-width: 190px; gap: 7px; }
.settings label > span { color: var(--muted); font-size: 12px; }
.settings output { color: var(--ink); font-variant-numeric: tabular-nums; }
.settings p { margin: 0 0 0 auto; color: var(--muted); font-size: 12px; }
.settings select { height: 34px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); padding: 0 8px; }
.settings input { accent-color: var(--ink); }

main {
  width: min(1720px, 100%);
  margin: 0 auto;
  padding: 38px clamp(18px, 3vw, 48px) 164px;
}

.mode-humanlm main,
.mode-editor main { padding-bottom: 54px; }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 440px);
  align-items: end;
  gap: 32px;
  margin-bottom: 30px;
}

.intro h1 { max-width: 760px; margin: 4px 0 0; font-size: clamp(36px, 5vw, 68px); font-weight: 500; letter-spacing: -.055em; line-height: .96; }
.intro > p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }

.chat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.checkpoint-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
}

.checkpoint-controls-copy { display: grid; gap: 3px; min-width: 126px; }
.checkpoint-controls-copy strong { font-size: 12px; }
.checkpoint-model-options { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.checkpoint-toggle-control { display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: 11px; font-weight: 750; cursor: pointer; }
.checkpoint-toggle-control:has(input:checked) { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.checkpoint-toggle-control input { accent-color: var(--ink); }
.checkpoint-toggle-control:has(input:disabled) { cursor: default; opacity: .55; }
.checkpoint-controls p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; }

.baseline-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.baseline-controls {
  display: grid;
  grid-template-columns: minmax(220px, .7fr) minmax(260px, 1fr) minmax(280px, 1.2fr);
  align-items: end;
  gap: 14px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
}

.baseline-controls label { display: grid; gap: 7px; }
.baseline-controls label > span { font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.baseline-controls select { width: 100%; padding: 10px 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; }
.baseline-controls select:disabled { color: var(--muted); opacity: 1; }
.baseline-controls p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.baseline-controls code { color: var(--ink); }
.baseline-panel .checkpoint-number { background: var(--paper); }
.comparison-panel { border-color: var(--ink); }
.comparison-panel .checkpoint-number { border-color: var(--ink); background: var(--accent); }

.shared-system-prompt {
  display: grid;
  grid-template-columns: minmax(170px, .32fr) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  margin-bottom: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
}

.shared-system-prompt label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.shared-system-prompt p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }

.shared-system-prompt textarea {
  width: 100%;
  min-height: 56px;
  max-height: 150px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--paper);
  color: var(--ink);
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.4;
}

.shared-system-prompt textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23, 23, 19, .06); }

.memory-overview {
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
}

.memory-overview > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.memory-overview h2 { margin: 4px 0 0; font-size: 15px; letter-spacing: -.02em; }

.memory-overview-controls { display: flex; align-items: center; gap: 14px; }
.memory-compare-control, .tool-toggle-control { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 700; cursor: pointer; }
.memory-compare-control input, .tool-toggle-control input { accent-color: var(--ink); }
.memory-compare-control:has(input:disabled), .tool-toggle-control:has(input:disabled) { cursor: default; opacity: .55; }
.memory-limit-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.memory-limit-control input { width: 56px; min-height: 32px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--paper); color: var(--ink); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; }
.memory-limit-control input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(23, 23, 19, .06); }
.memory-limit-control input:disabled { opacity: .55; }

.memory-graph-toggle {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--paper);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.memory-graph-toggle:hover,
.memory-graph-toggle[aria-expanded="true"] { border-color: var(--ink); background: var(--ink); color: var(--surface); }

.memory-active {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.memory-active::before { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); content: ""; }
.memory-active.is-active { color: var(--ink); }
.memory-active.is-active::before { background: #73a657; box-shadow: 0 0 0 3px color-mix(in srgb, #73a657 18%, transparent); }

.memory-systems { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: stretch; }

.memory-system {
  min-width: 0;
  border-right: 1px solid var(--line);
}

.memory-system:last-child { border-right: 0; }
.memory-system.is-active { background: color-mix(in srgb, var(--accent) 17%, var(--surface)); }
.memory-system > header { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.memory-system > header > div { min-width: 0; }
.memory-system strong, .memory-system > header > div > span { display: block; }
.memory-system strong { font-size: 12px; }
.memory-system > header > div > span { margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.memory-system-results { max-height: 360px; min-height: 78px; overflow-y: auto; padding: 10px; border-top: 1px solid var(--line); background: var(--surface); scrollbar-width: thin; }
.memory-system.is-active .memory-system-results { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.memory-system-results > .memory-empty { padding: 10px 6px; }

.memory-system-status {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
}

.memory-system-status:disabled { cursor: default; opacity: .58; }

.memory-system.is-active .memory-system-status { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.memory-loading { grid-column: 1 / -1; margin: 0; padding: 16px; color: var(--muted); font-size: 11px; }
.memory-overview-note { margin: 0; padding: 9px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.4; }

.memory-graph-panel { border-top: 1px solid var(--line-strong); background: var(--paper); }
.memory-graph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.memory-graph-header h3 { margin: 4px 0 0; font-size: 18px; letter-spacing: -.025em; }
.memory-graph-header > div:first-child > p:last-child { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.memory-graph-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.memory-graph-actions button {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}
.memory-graph-actions button:hover { border-color: var(--ink); }
.memory-graph-actions button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.memory-graph-body { display: grid; min-height: 520px; grid-template-columns: minmax(0, 1.55fr) minmax(330px, .65fr); }
.memory-graph-stage { position: relative; min-width: 0; overflow: hidden; border-right: 1px solid var(--line); background: var(--surface); }
.memory-graph-stage::before {
  position: absolute;
  inset: 0;
  opacity: .32;
  background-image: radial-gradient(circle, var(--line-strong) 1px, transparent 1px);
  background-size: 20px 20px;
  content: "";
  pointer-events: none;
}
#memory-graph-svg { position: relative; display: block; width: 100%; height: 520px; cursor: grab; touch-action: none; }
#memory-graph-svg.is-panning { cursor: grabbing; }
.memory-graph-help { position: absolute; right: 12px; bottom: 10px; margin: 0; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--muted); font-size: 8px; pointer-events: none; }
.memory-graph-edges line { stroke: var(--graph-edge); stroke-opacity: .34; stroke-width: 1.2; }
.memory-graph-edges line.is-retrieved { stroke: var(--ink); stroke-opacity: .72; stroke-width: 1.8; }
#graph-arrow path { fill: var(--graph-edge); }
.memory-graph-node { cursor: pointer; }
.memory-graph-node circle { stroke: var(--surface); stroke-width: 2; transition: stroke-width .12s ease, r .12s ease; }
.memory-graph-node[data-node-kind="entity"] circle { fill: var(--graph-entity); }
.memory-graph-node[data-node-kind="value"] circle { fill: var(--graph-value); }
.memory-graph-node[data-node-kind="memory"] circle { fill: var(--graph-memory); }
.memory-graph-node.is-retrieved circle { stroke: var(--ink); stroke-width: 3; }
.memory-graph-node.is-selected circle { stroke: var(--accent); stroke-width: 6; }
.memory-graph-node text { fill: var(--ink); font-size: 9px; font-weight: 700; paint-order: stroke; pointer-events: none; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }

.memory-relationships { min-width: 0; max-height: 520px; overflow-y: auto; background: var(--paper); scrollbar-width: thin; }
.memory-relationships > header { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(9px); }
.memory-relationships h4 { margin: 4px 0 0; font-size: 14px; }
.memory-relationships > header > span { display: grid; min-width: 28px; height: 28px; place-items: center; border-radius: 999px; background: var(--ink); color: var(--surface); font-size: 9px; font-weight: 800; font-variant-numeric: tabular-nums; }
.memory-relationship-note { margin: 0; padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.45; }
.memory-relationship-list { display: grid; gap: 8px; padding: 10px; }
.memory-relationship { overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.memory-relationship-triplet { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 5px; padding: 9px; }
.graph-node-chip,
.graph-predicate-chip { min-width: 0; border-radius: 6px; font-size: 9px; font-weight: 750; line-height: 1.2; }
.graph-node-chip { overflow: hidden; padding: 7px 6px; border: 1px solid transparent; color: #fff; cursor: pointer; text-overflow: ellipsis; white-space: nowrap; }
.graph-node-chip:hover { filter: brightness(.91); }
.graph-node-chip[data-node-kind="entity"] { background: var(--graph-entity); }
.graph-node-chip[data-node-kind="value"] { background: var(--graph-value); }
.graph-node-chip[data-node-kind="memory"] { background: var(--graph-memory); }
.graph-node-chip[data-node-kind="unknown"] { background: var(--graph-edge); }
.graph-predicate-chip { position: relative; padding: 5px 7px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); text-align: center; }
.graph-predicate-chip::before,
.graph-predicate-chip::after { position: absolute; top: 50%; width: 6px; border-top: 1px solid var(--graph-edge); content: ""; }
.graph-predicate-chip::before { right: 100%; }
.graph-predicate-chip::after { left: 100%; }
.memory-relationship > p { margin: 0; padding: 0 10px 10px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.memory-graph-empty { margin: 0; padding: 14px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.memory-graph-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 9px; }
.memory-graph-legend span { display: inline-flex; align-items: center; gap: 5px; }
.memory-graph-legend i { width: 9px; height: 9px; border-radius: 50%; }
.memory-graph-legend i[data-node-kind="entity"] { background: var(--graph-entity); }
.memory-graph-legend i[data-node-kind="value"] { background: var(--graph-value); }
.memory-graph-legend i[data-node-kind="memory"] { background: var(--graph-memory); }
.memory-graph-legend i.is-evidence { width: 16px; height: 0; border-top: 2px solid var(--ink); border-radius: 0; }

.chat-panel {
  display: grid;
  min-width: 0;
  min-height: clamp(420px, 54vh, 680px);
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.chat-panel[data-checkpoint="10"] { border-color: var(--ink); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 7px;
}

.panel-header > div { display: flex; align-items: center; gap: 10px; }
.checkpoint-number { display: grid; min-width: 31px; height: 31px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 12px; font-weight: 700; }
.chat-panel[data-checkpoint="10"] .checkpoint-number { border-color: var(--ink); background: var(--accent); }
.panel-header h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.02em; }
.panel-detail { margin: 0; padding: 0 18px 17px 59px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }


.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.status i { width: 6px; height: 6px; border-radius: 50%; background: #73a657; }
.chat-panel.is-loading .status i { background: #d2a83c; animation: pulse 1s ease-in-out infinite; }
.chat-panel.has-error .status i { background: var(--danger); }
.status.is-loading i { background: #d2a83c; animation: pulse 1s ease-in-out infinite; }
.status.has-error i { background: var(--danger); }

.messages {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 22px 18px 26px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.empty-state { display: grid; min-height: 100%; place-content: center; padding: 44px 28px; text-align: center; }
.empty-state span { color: var(--line-strong); font-size: clamp(34px, 5vw, 58px); font-weight: 500; letter-spacing: -.06em; }
.empty-state p { max-width: 240px; margin: 12px auto 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.message { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; animation: rise .22s ease-out both; }
.message.user { align-items: flex-end; }
.message-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.bubble { max-width: 92%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; background: var(--paper); font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.user .bubble { border-color: var(--user); border-radius: 14px 14px 4px 14px; background: var(--user); color: var(--user-ink); }
.message.error .bubble { border-color: color-mix(in srgb, var(--danger) 32%, var(--line)); background: #fff7f5; color: var(--danger); }
.message-meta { color: var(--muted); font-size: 10px; }
.assistant .bubble { white-space: normal; }
.assistant .bubble p { margin: 0 0 9px; }
.assistant .bubble p:last-child { margin-bottom: 0; }
.assistant .bubble h3, .assistant .bubble h4, .assistant .bubble h5 { margin: 14px 0 6px; font-size: 14px; line-height: 1.35; }
.assistant .bubble h3:first-child, .assistant .bubble h4:first-child, .assistant .bubble h5:first-child { margin-top: 0; }
.assistant .bubble ul, .assistant .bubble ol { margin: 5px 0 10px; padding-left: 20px; }
.assistant .bubble li { margin: 3px 0; }
.assistant .bubble hr { margin: 13px 0; border: 0; border-top: 1px solid var(--line); }
.assistant .bubble code { padding: 1px 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); font: .9em ui-monospace, SFMono-Regular, Menlo, monospace; }

.memory-empty { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.memory-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; counter-reset: memories; }
.memory-list li { position: relative; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); counter-increment: memories; }
.memory-list li::before { position: absolute; top: 10px; right: 10px; color: var(--muted); content: counter(memories, decimal-leading-zero); font-size: 9px; font-variant-numeric: tabular-nums; }
.memory-list p { margin: 0; padding-right: 22px; font-size: 11px; line-height: 1.45; }
.memory-metadata { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.memory-metadata span, .memory-metadata a { padding: 3px 5px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 8px; line-height: 1; text-decoration: none; }
.memory-metadata a:hover { border-color: var(--ink); color: var(--ink); }

.tool-actions { display: flex; max-width: 92%; flex-wrap: wrap; gap: 5px; }
.tool-action { padding: 4px 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; }
.tool-action.is-error { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); color: var(--danger); }

.typing { display: inline-flex; height: 40px; align-items: center; gap: 4px; padding: 0 13px; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; background: var(--paper); }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.composer-wrap {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 22px 18px 12px;
  background: linear-gradient(to bottom, transparent, var(--paper) 22%, var(--paper));
}

.prompt-examples {
  display: grid;
  width: min(850px, 100%);
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0 auto 7px;
  color: var(--muted);
  font-size: 10px;
}

.prompt-examples > span { white-space: nowrap; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.prompt-example-list {
  display: flex;
  min-width: 0;
  gap: 6px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}
.prompt-examples button {
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 5px 9px;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  scroll-snap-align: start;
  white-space: nowrap;
}
.prompt-examples button:hover { border-color: var(--ink); background: var(--accent); color: var(--accent-ink); }
.prompt-examples button:disabled { cursor: wait; opacity: .45; }

.composer {
  display: flex;
  width: min(850px, 100%);
  align-items: flex-end;
  gap: 10px;
  margin: 0 auto;
  padding: 9px 9px 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(25, 24, 18, .08);
}

.composer:focus-within { border-color: var(--ink); box-shadow: 0 8px 30px rgba(25, 24, 18, .08), 0 0 0 3px rgba(23, 23, 19, .06); }
.composer textarea { width: 100%; max-height: 150px; resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 15px; line-height: 1.45; }
.composer textarea::placeholder { color: #96948b; }
.composer button { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border: 0; border-radius: 11px; background: var(--ink); color: var(--surface); cursor: pointer; }
.composer button:disabled { cursor: not-allowed; opacity: .3; }
.composer svg { width: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.composer-wrap > p { margin: 8px auto 0; color: var(--muted); font-size: 10px; text-align: center; }

.humanlm-intro { margin-bottom: 36px; }

.persona-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(360px, 1.1fr);
  gap: 14px;
  align-items: stretch;
}

.persona-form,
.persona-result {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.persona-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
}

.persona-form label { display: grid; gap: 4px; margin-top: 4px; }
.persona-form label span { font-size: 13px; font-weight: 700; }
.persona-form label small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.persona-form textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--paper);
  color: var(--ink);
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.persona-form textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23, 23, 19, .06); }

.primary-button {
  min-height: 46px;
  margin-top: 5px;
  border: 1px solid var(--ink);
  border-radius: 11px;
  background: var(--ink);
  color: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.primary-button:hover { opacity: .88; }
.primary-button:disabled { cursor: wait; opacity: .45; }
.form-note { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; text-align: center; }

.persona-result {
  display: grid;
  min-height: 600px;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border-color: var(--ink);
}
.persona-result > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}
.persona-result h2 { margin: 5px 0 0; font-size: 19px; letter-spacing: -.025em; }
.persona-output { min-height: 0; overflow-y: auto; padding: 26px; }
.persona-output .empty-state span { color: var(--line-strong); }
.persona-answer { font-size: clamp(17px, 2vw, 23px); line-height: 1.55; letter-spacing: -.015em; }
.persona-answer p { margin: 0 0 16px; }
.persona-answer p:last-child { margin-bottom: 0; }
.persona-answer ul, .persona-answer ol { padding-left: 24px; }
.persona-meta { margin: 24px 0 0; color: var(--muted); font-size: 10px; }
.persona-loading { display: grid; min-height: 100%; place-content: center; justify-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.persona-loading p { margin: 0; }
.persona-error { padding: 14px; border: 1px solid color-mix(in srgb, var(--danger) 32%, var(--line)); border-radius: 10px; background: #fff7f5; color: var(--danger); font-size: 13px; line-height: 1.45; }

.editor-intro { margin-bottom: 28px; }

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, .75fr);
  gap: 14px;
  align-items: stretch;
}

.document-panel,
.editor-agent {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.document-panel { display: grid; min-height: 680px; grid-template-rows: auto auto 1fr auto; }
.document-panel > header,
.editor-agent > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.document-panel h2,
.editor-agent h2 { margin: 4px 0 0; font-size: 18px; letter-spacing: -.025em; }

.editor-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.secondary-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 650;
}
.secondary-button:hover { border-color: var(--ink); }
.secondary-button:disabled { cursor: wait; opacity: .45; }

.document-metadata {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.document-metadata label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.document-metadata input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.document-metadata a { color: var(--muted); font-size: 10px; }
.document-panel > textarea {
  width: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  outline: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 24px;
  font: 14px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  tab-size: 2;
}
.document-panel > textarea:focus { box-shadow: inset 0 0 0 2px var(--line-strong); }
.document-counter { margin: 0; padding: 8px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; text-align: right; }

.editor-agent {
  display: flex;
  min-height: 680px;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 18px;
}
.editor-agent > header { margin-bottom: 4px; }
.editor-agent > label,
.editor-agent > select,
.editor-agent > textarea,
.editor-agent > button,
.editor-agent > .form-note { margin-right: 20px; margin-left: 20px; }
.editor-agent > label { display: grid; gap: 4px; margin-top: 4px; }
.editor-agent > label span { font-size: 13px; font-weight: 700; }
.editor-agent > label small { color: var(--muted); font-size: 10px; line-height: 1.4; }
.editor-agent > select,
.editor-agent > textarea {
  width: calc(100% - 40px);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: var(--paper);
  color: var(--ink);
  padding: 10px;
  font-size: 12px;
}
.editor-agent > select { min-height: 40px; }
.editor-agent > textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
.editor-agent > select:focus,
.editor-agent > textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23, 23, 19, .06); }
.editor-output {
  min-height: 180px;
  margin: 8px 20px 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}
.editor-output > .empty-state { min-height: 180px; padding: 24px; }
.editor-output > .empty-state span { font-size: 28px; }
.editor-result { padding: 16px; }
.editor-result h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.editor-result-message { font-size: 13px; line-height: 1.5; }
.editor-result-message p { margin: 0 0 8px; }
.editor-result-meta { margin: 10px 0 0; color: var(--muted); font-size: 9px; }
.editor-output .memory-list p { font-size: 10px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes rise { from { transform: translateY(5px); opacity: 0; } }

@media (max-width: 1023px) {
  main { padding-top: 28px; }
  .intro { grid-template-columns: 1fr; gap: 16px; }
  .intro > p { max-width: 580px; }
  .memory-systems { grid-template-columns: 1fr; }
  .memory-system { border-right: 0; border-bottom: 1px solid var(--line); }
  .memory-system:last-child { border-bottom: 0; }
  .memory-graph-body { grid-template-columns: 1fr; }
  .memory-graph-stage { border-right: 0; border-bottom: 1px solid var(--line); }
  .memory-relationships { max-height: 420px; }
  .chat-grid { grid-auto-columns: minmax(330px, 48vw); grid-template-columns: none; grid-auto-flow: column; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
  .baseline-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .baseline-controls p { grid-column: 1 / -1; }
  .chat-panel { scroll-snap-align: start; }
  .mode-switch { position: static; transform: none; }
  .persona-grid { grid-template-columns: 1fr; }
  .persona-result { min-height: 440px; }
  .editor-grid { grid-template-columns: 1fr; }
  .document-panel, .editor-agent { min-height: 560px; }
}

@media (max-width: 767px) {
  .topbar { min-height: 62px; padding: 10px 14px; }
  .brand small { display: none; }
  .topbar { flex-wrap: wrap; }
  .mode-switch { order: 3; width: 100%; margin-top: 8px; }
  .mode-button { flex: 1; padding: 0 8px; }
  .brand-mark { width: 34px; height: 34px; }
  .text-button { min-height: 44px; padding: 0 9px; font-size: 12px; }
  .settings { top: 113px; flex-wrap: wrap; gap: 14px; padding: 14px; }
  .settings label { min-width: calc(50% - 7px); }
  .settings p { width: 100%; margin: 0; }
  main { padding: 24px 14px 150px; }
  .intro { margin-bottom: 22px; }
  .intro h1 { font-size: clamp(38px, 12vw, 54px); }
  .shared-system-prompt { grid-template-columns: 1fr; gap: 10px; }
  .checkpoint-controls { grid-template-columns: 1fr; align-items: flex-start; gap: 10px; }
  .checkpoint-model-options { justify-content: flex-start; }
  .memory-overview > header { align-items: flex-start; flex-direction: column; gap: 9px; }
  .memory-overview-controls { width: 100%; justify-content: space-between; }
  .memory-graph-header { align-items: flex-start; flex-direction: column; }
  .memory-graph-actions { width: 100%; justify-content: flex-start; }
  .memory-graph-actions button { flex: 1 1 auto; }
  #memory-graph-svg { height: 430px; }
  .memory-graph-body { min-height: 430px; }
  .memory-relationship-triplet { grid-template-columns: minmax(0, 1fr); }
  .graph-predicate-chip::before,
  .graph-predicate-chip::after { display: none; }
  .chat-grid { grid-auto-columns: min(88vw, 390px); margin-right: -14px; padding-right: 14px; }
  .baseline-controls { grid-template-columns: 1fr; }
  .baseline-controls p { grid-column: auto; }
  .chat-panel { min-height: 52vh; }
  .composer-wrap { padding: 18px 10px 9px; }
  .persona-form { padding: 16px; }
  .persona-output { padding: 20px; }
  .persona-result { min-height: 380px; }
  .document-panel > header { align-items: flex-start; flex-direction: column; }
  .editor-actions { justify-content: flex-start; }
  .document-metadata { grid-template-columns: auto 1fr; }
  .document-metadata a { grid-column: 1 / -1; }
  .document-panel { min-height: 70vh; }
}

@media (max-width: 374px) {
  .brand strong { font-size: 13px; }
  .text-button { padding: 0 7px; }
  .topbar-actions { gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #171714;
    --surface: #20201c;
    --ink: #f4f2e8;
    --muted: #aaa89f;
    --line: #37362f;
    --line-strong: #4a4940;
    --accent-ink: #202500;
    --user: #efede4;
    --user-ink: #1c1c18;
    --danger: #ff8b79;
    --graph-entity: #6796ec;
    --graph-value: #e79a47;
    --graph-memory: #9c82e2;
    --graph-edge: #a8a59c;
  }
  .message.error .bubble { background: #301d19; }
}
