* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: #e8e8ee;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.ls-root {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
  padding: 12px;
  gap: 12px;
  overflow-x: hidden;
  overflow-y: hidden;
}

.ls-left-column {
  order: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 1 460px;
  min-height: 0;
  min-width: 360px;
  max-width: 520px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

.ls-process-column {
  order: 2;
  display: flex;
  flex-direction: column;
  flex: 0 1 360px;
  min-height: 0;
  min-width: 280px;
  max-width: 420px;
}

.ls-middle-column {
  order: 3;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 560px;
  min-height: 0;
  min-width: 420px;
}

.ls-right-column {
  order: 4;
  display: flex;
  flex-direction: column;
  flex: 0 1 360px;
  gap: 10px;
  min-height: 0;
  min-width: 300px;
  max-width: 360px;
}

.ls-emulator-debug,
.ls-group-create-panel {
  flex: 0 0 auto;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.ls-group-create-panel > .ls-section,
.ls-emulator-debug > .ls-section {
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.ls-group-create-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.ls-group-create-summary-label {
  flex: 0 0 auto;
}

.ls-group-create-summary-note {
  margin-left: auto;
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  font-size: 10px;
  font-weight: 400;
  color: #94a3b8;
  line-height: 1.2;
}

.ls-name-resolution-panel {
  padding: 4px 12px 0;
  font-size: 11px;
  line-height: 1.4;
  color: #334155;
}

.ls-name-resolution-dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
}

.ls-name-resolution-dl dt {
  font-weight: 600;
  color: #64748b;
}

.ls-name-resolution-dl dd {
  margin: 0;
  font-family: ui-monospace, monospace;
  word-break: break-word;
}

.ls-name-resolution-note {
  margin: 0;
  font-size: 10px;
  color: #64748b;
}

.ls-name-resolution-actions {
  display: flex;
  gap: 6px;
  padding: 6px 12px 8px;
  border-top: none;
}

.ls-name-resolution-actions input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #ddd;
  font-size: 12px;
}

.ls-name-resolution-subhead {
  padding: 4px 12px 0;
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.ls-group-chat-lab-lead {
  padding: 6px 12px 4px;
  margin: 0;
}

.ls-group-chat-lab-secondary {
  padding-top: 0;
  border-top: none;
}

.ls-group-chat-lab-panel {
  padding-top: 4px;
}

.ls-group-test-setup {
  padding: 0 12px 6px;
}

.ls-group-test-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  margin: 4px 0 2px;
}

.ls-group-field-row.ls-name-resolution-actions {
  padding: 0 12px 4px;
}

.ls-group-roster-textarea {
  display: block;
  width: calc(100% - 24px);
  box-sizing: border-box;
  margin: 0 12px 4px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid #ddd;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  line-height: 1.35;
  resize: vertical;
  min-height: 2.75em;
}

.ls-group-setup-btn {
  flex: 1;
  background: #0f766e !important;
}

.ls-group-test-active {
  padding: 0 12px 2px;
}

.ls-group-participant-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 2px 0 4px;
}

.ls-group-participant-chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  font-size: 11px;
  cursor: pointer;
  font-family: ui-monospace, monospace;
  color: #334155;
}

.ls-group-participant-chip:hover {
  border-color: #0f766e;
  background: #ecfdf5;
}

.ls-group-participant-chip.is-selected {
  border-color: #0f766e;
  background: #ccfbf1;
  font-weight: 600;
}

.ls-name-resolution-actions button {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  background: #475569;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.ls-nuke-panel {
  flex: 0 0 auto;
}

.ls-nuke-btn {
  width: 100%;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid rgba(154, 52, 18, 0.35);
  border-radius: 8px;
  cursor: pointer;
  background: linear-gradient(180deg, #fb923c 0%, #ea580c 55%, #c2410c 100%);
  color: #fffaf5;
  box-shadow: 0 1px 3px rgba(194, 65, 12, 0.28);
}

.ls-nuke-btn:hover {
  filter: brightness(1.04);
  box-shadow: 0 2px 6px rgba(194, 65, 12, 0.35);
}

.ls-nuke-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(194, 65, 12, 0.25);
}

.ls-nuke-hint {
  margin: 6px 0 0;
  font-size: 10px;
  color: #64748b;
  line-height: 1.35;
}

@media (max-width: 1560px) {
  .ls-left-column {
    flex-basis: 410px;
    min-width: 320px;
  }
  .ls-process-column {
    flex-basis: 320px;
    min-width: 240px;
  }
  .ls-middle-column {
    min-width: 360px;
  }
  .ls-right-column {
    min-width: 280px;
    max-width: 340px;
  }
}

@media (max-width: 1320px) {
  .ls-root {
    flex-wrap: wrap;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .ls-left-column,
  .ls-process-column,
  .ls-middle-column,
  .ls-right-column {
    min-width: 0;
    max-width: none;
  }
  .ls-left-column {
    order: 1;
    flex: 1 1 calc(34% - 8px);
  }
  .ls-middle-column {
    order: 2;
    flex: 1 1 calc(38% - 8px);
  }
  .ls-right-column {
    order: 3;
    flex: 1 1 calc(28% - 8px);
  }
  .ls-process-column {
    order: 4;
    flex: 1 1 100%;
  }
}

@media (max-width: 980px) {
  .ls-root {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-y: auto;
  }
  .ls-left-column,
  .ls-process-column,
  .ls-middle-column,
  .ls-right-column {
    order: initial;
    flex: 1 1 auto;
    width: 100%;
  }
}

.ls-process-panel {
  flex: 1;
}

.ls-process-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  min-height: 0;
  flex: 1;
}

.ls-process-log-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 12px;
  overflow: hidden;
}

.ls-process-log-headbar {
  flex: 0 0 auto;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #fafafa;
  border-bottom: 1px solid #eee;
}

.ls-process-kv {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  min-height: 3.2em;
  max-height: 8em;
  resize: none;
  white-space: pre-wrap;
}

.ls-heartbeat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 4.5em;
}

.ls-heartbeat-status {
  line-height: 1.35;
}

.ls-heartbeat-session--in {
  color: #2563eb;
  font-weight: 600;
}

.ls-heartbeat-session--off {
  color: #94a3b8;
  font-weight: 500;
}

.ls-heartbeat-clock {
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  font-size: 0.78em;
}

.ls-process-log {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 12px 16px;
}

.ls-process-column .ls-section summary {
  padding: 8px 10px;
}

.ls-process-column .ls-section .ls-body {
  resize: none;
  max-height: none;
}

.ls-process-log-item {
  border: 1px solid #dbeafe;
  background: #eff6ff;
  border-radius: 10px;
  padding: 8px 9px;
  font-size: 11px;
  line-height: 1.35;
  color: #1e3a8a;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.ls-process-log-item.ls-process-log-item--green {
  border-color: #86efac;
  background: #ecfdf5;
  color: #166534;
}

.ls-process-log-item.ls-process-log-item--green .ls-process-log-head {
  color: #15803d;
}

.ls-process-log-head {
  font-size: 9px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  color: #475569;
  margin-bottom: 4px;
}

.ls-panel {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ls-panel-graph {
  flex: 0 0 auto;
}

.ls-panel-list {
  flex: 1 1 220px;
  min-height: 180px;
  overflow: hidden;
}

/* Resizable list panels in the left column (memPersons / memStories / memSums / transcripts). */
.ls-panel-list-resizable {
  flex: 0 0 auto;
  height: 130px;
  min-height: 90px;
  resize: vertical;
  overflow: auto;
  max-height: min(78vh, 1300px);
}

.ls-panel-head {
  font-weight: 600;
  font-size: 12px;
  padding: 8px 12px;
  background: #fafafa;
  border-bottom: 1px solid #eee;
  border-radius: 12px 12px 0 0;
}

.ls-panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ls-panel-head-total {
  font-weight: 500;
  font-size: 11px;
  color: #64748b;
  flex-shrink: 0;
}

.ls-mem-head-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.ls-mem-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ls-panel-refresh {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
}

.ls-panel-refresh:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ls-triple-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
  cursor: pointer;
}

.ls-triple-expand-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #1e293b;
}

.ls-triple-expand-btn:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 1px;
}

.ls-triple-expand-icon {
  flex-shrink: 0;
}

.ls-triple-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  box-sizing: border-box;
}

.ls-triple-modal[hidden] {
  display: none !important;
}

/* Above default `.ls-modal-backdrop` (1300) so this list stays on top of memStory/memSum/transcript modals. */
.ls-mempersons-modal.ls-triple-modal {
  z-index: 1350;
}

.ls-triple-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.ls-triple-modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(96vw, 1120px);
  max-height: min(88vh, 900px);
  border-radius: 12px;
  background: #fff;
  box-shadow:
    0 24px 48px rgba(15, 23, 42, 0.18),
    0 0 0 1px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.ls-triple-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #fafafa;
  flex-shrink: 0;
}

.ls-triple-modal-title {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.ls-triple-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.ls-triple-modal-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.ls-triple-modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ls-triples-review-modal {
  z-index: 1250;
}

.ls-full-prompt-section {
  position: relative;
}

.ls-full-prompt-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

.ls-full-prompt-summary-label {
  flex: 1;
  min-width: 0;
}

.ls-full-prompt-summary-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ls-full-prompt-token-meta {
  font-size: 10px;
  font-weight: 400;
  color: #64748b;
  white-space: nowrap;
  line-height: 1.2;
}

.ls-process-column .ls-full-prompt-summary {
  padding: 8px 10px;
}

.ls-full-system-prompt-modal .ls-triple-modal-head {
  gap: 10px;
}

.ls-full-prompt-modal-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.ls-full-prompt-modal-token-meta {
  font-size: 10px;
  font-weight: 400;
  color: #94a3b8;
  white-space: nowrap;
}

.ls-full-system-prompt-modal-panel {
  width: min(96vw, 960px);
  max-height: min(92vh, 960px);
}

.ls-full-system-prompt-modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px 16px;
  background: #f8fafc;
}

.ls-full-system-prompt-pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #0f172a;
}

.ls-triples-review-panel {
  width: min(92vw, 640px);
  max-height: min(86vh, 720px);
}

.ls-triples-review-toolbar {
  flex-shrink: 0;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}

.ls-triples-review-search {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
  background: #f8fafc;
}

.ls-triples-review-search:focus {
  outline: 2px solid #38bdf8;
  outline-offset: 1px;
  border-color: #7dd3fc;
  background: #fff;
}

.ls-triples-review-trunc-hint {
  margin: 0;
  padding: 6px 14px 0;
  font-size: 11px;
  line-height: 1.35;
  color: #b45309;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  flex-shrink: 0;
}

.ls-triples-review-trunc-hint[hidden] {
  display: none !important;
}

.ls-triples-review-body {
  flex: 1;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fafafa;
}

.ls-triples-review-list {
  flex: 1;
  min-height: 0;
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

button.ls-triples-review-item {
  text-align: left;
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  padding: 6px 9px 7px;
  font-size: 11px;
  line-height: 1.4;
  color: #334155;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  transition: background 0.12s, border-color 0.12s;
}

button.ls-triples-review-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

button.ls-triples-review-item:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 1px;
}

button.ls-triples-review-item.ls-triples-review-item-active {
  background: #e0f2fe;
  border-color: #38bdf8;
}

.ls-triples-review-last-session-note {
  font-size: 9px;
  color: #64748b;
  opacity: 0.95;
}

.ls-triples-review-audit {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.ls-triples-review-audit-nonsense {
  color: #9a3412;
  background: #ffedd5;
  border: 1px solid #fdba74;
}

.ls-triples-review-audit-contradiction {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fca5a5;
}

.ls-triples-review-audit-kept {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #86efac;
}

.ls-triple-inspector-audit {
  color: #9a3412;
  font-weight: 600;
}

.ls-triples-review-empty {
  margin: 0;
  padding: 12px 4px;
  font-size: 12px;
  line-height: 1.4;
  color: #64748b;
}

.ls-triple-modal-viewport {
  position: relative;
  flex: 1;
  min-height: 280px;
  height: min(72vh, 760px);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.ls-triple-modal-viewport:active {
  cursor: grabbing;
}

.ls-triple-modal-viewport .ls-graph-node {
  cursor: grab;
}

.ls-triple-modal-viewport .ls-graph-node:active {
  cursor: grabbing;
}

.ls-triple-modal-viewport svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ls-triple-modal-meta {
  flex-shrink: 0;
  padding: 6px 14px 6px;
  line-height: 1.35;
  border-top: 1px solid #f1f5f9;
}

.ls-triple-modal-last-wrap {
  flex-shrink: 0;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 8px 12px 10px;
  max-height: min(22vh, 200px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.ls-triple-modal-last-wrap[hidden] {
  display: none !important;
}

.ls-triple-modal-last-head {
  font-size: 10px;
  font-weight: 600;
  color: #475569;
  line-height: 1.3;
}

.ls-triple-modal-last-head .ls-triple-modal-last-sub {
  font-weight: 400;
  color: #64748b;
  display: block;
  margin-top: 2px;
  font-size: 9px;
  word-break: break-all;
}

.ls-triple-modal-last-list {
  overflow: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}

button.ls-triple-modal-last-item {
  text-align: left;
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  padding: 5px 8px 6px;
  font-size: 10px;
  line-height: 1.35;
  color: #334155;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}

button.ls-triple-modal-last-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

button.ls-triple-modal-last-item:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 1px;
}

button.ls-triple-modal-last-item.ls-triple-modal-last-item-active {
  background: #e0f2fe;
  border-color: #38bdf8;
}

.ls-triple-modal-last-empty {
  font-size: 10px;
  color: #94a3b8;
  padding: 2px 0;
}

.ls-triple-modal-inspector {
  flex-shrink: 0;
  border-top: 1px solid #e2e8f0;
  background: #fafafa;
}

.ls-triple-graph-viewport {
  position: relative;
  min-height: 220px;
  height: min(32vh, 320px);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.ls-triple-graph-viewport:active {
  cursor: grabbing;
}

.ls-graph-node {
  cursor: grab;
}

.ls-graph-node:active {
  cursor: grabbing;
}

.ls-graph-node-emoji {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  pointer-events: none;
  user-select: none;
}

.ls-triple-graph-viewport svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ls-graph-bg {
  fill: #fafafa;
}

.ls-triple-graph-meta {
  font-size: 10px;
  color: #777;
  padding: 4px 10px 8px;
}

.ls-triple-inspector {
  border-top: 1px solid #eee;
  padding: 6px 10px 8px;
  font-size: 10px;
  color: #475569;
  line-height: 1.35;
}

.ls-triple-inspector-placeholder {
  color: #94a3b8;
  font-size: 10px;
}

.ls-triple-inspector-detail {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ls-triple-inspector-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ls-triple-inspector-main {
  font-size: 10px;
  line-height: 1.35;
  color: #64748b;
}

.ls-triple-inspector-tuple {
  word-break: break-word;
  color: #334155;
}

.ls-triple-inspector-meta {
  font-size: 10px;
  line-height: 1.35;
  color: #64748b;
}

button.ls-inspector-src-link {
  display: inline;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  font: inherit;
  color: #2563eb;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

button.ls-inspector-src-link:hover {
  color: #1d4ed8;
}

.ls-triple-inspector-delete {
  flex-shrink: 0;
  align-self: center;
}

.ls-graph-edge-hit {
  cursor: pointer;
}

.ls-graph-edge-label {
  cursor: pointer;
}

/* Associative recall highlight (triples_graph.recall_pulse) — CSS animations work reliably on SVG */
@keyframes ls-graph-recall-edge-line {
  0%,
  100% {
    filter: none;
  }
  40% {
    stroke: #f59e0b !important;
    stroke-width: 5px !important;
    stroke-opacity: 1 !important;
    filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.95));
  }
}

@keyframes ls-graph-recall-edge-label {
  0%,
  100% {
    filter: none;
  }
  40% {
    fill: #ea580c !important;
    stroke: #fffbeb !important;
    stroke-width: 10px !important;
    filter: drop-shadow(0 0 6px rgba(251, 146, 60, 0.9));
  }
}

@keyframes ls-graph-recall-node-viz {
  0%,
  100% {
    filter: none;
  }
  40% {
    fill: #fef3c7 !important;
    stroke: #ea580c !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.9));
  }
}

.ls-graph-edge.ls-graph-recall-flash .ls-graph-edge-line {
  animation: ls-graph-recall-edge-line 0.95s ease-out;
}

.ls-graph-edge.ls-graph-recall-flash .ls-graph-edge-label {
  animation: ls-graph-recall-edge-label 0.95s ease-out;
}

.ls-graph-node.ls-graph-recall-flash .ls-graph-node-viz {
  animation: ls-graph-recall-node-viz 0.95s ease-out;
}

.ls-scroll-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 6px 8px 10px;
  font-size: 12px;
}

.ls-mem-row,
.ls-tr-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 8px;
  margin-bottom: 6px;
  border-radius: 8px;
  border: 1px solid #eee;
  cursor: pointer;
  background: #fdfdfd;
}

.ls-mem-row:hover,
.ls-tr-row:hover {
  background: #f0f4ff;
  border-color: #c7d2fe;
}

.ls-mem-row-main {
  flex: 1;
  min-width: 0;
}

.ls-mem-row-label {
  line-height: 1.35;
  word-break: break-word;
}

.ls-mempersons-list {
  font-size: 11px;
}

.ls-memperson-merge-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 8px 10px;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
  overflow-x: auto;
}

.ls-memperson-merge-label {
  color: #64748b;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ls-memperson-merge-input {
  width: 72px;
  padding: 4px 6px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 11px;
  background: #fff;
}

.ls-memperson-merge-input-wide {
  flex: 1 1 140px;
  min-width: 0;
}

.ls-memperson-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  margin-bottom: 6px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fdfdfd;
  cursor: pointer;
}

.ls-memperson-row:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.ls-memmeta-panel-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin: 10px 0 4px;
  padding: 0 2px;
}

.ls-memmeta-section .ls-memmeta-panel-label:first-of-type {
  margin-top: 4px;
}

.ls-memmeta-behavioral {
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.45;
  color: #7c2d12;
  background: #fff7ed;
  border-radius: 6px;
  padding: 8px 10px;
  border: 1px solid #fed7aa;
}

/* Singleton memMeta — always first in memPersons list */
.ls-memmeta-row {
  border-color: #86efac;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 55%, #f8fafc 100%);
  margin-bottom: 10px;
}

.ls-memmeta-row:hover {
  background: linear-gradient(135deg, #dcfce7 0%, #ecfdf5 55%, #f1f5f9 100%);
  border-color: #4ade80;
}

.ls-memmeta-row .ls-memperson-row-name {
  color: #166534;
}

.ls-memmeta-row-kind {
  color: #15803d;
  font-weight: 600;
}

.ls-mempersons-empty-hint {
  font-size: 11px;
  color: #94a3b8;
  padding: 4px 8px 8px;
  font-style: italic;
}

.ls-memperson-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.ls-memperson-row-head-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
}

.ls-memperson-row-delete {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  cursor: pointer;
  line-height: 1.2;
}

.ls-memperson-row-delete:hover {
  background: #fee2e2;
}

.ls-memperson-row-backfill {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #86efac;
  background: #ecfdf5;
  color: #166534;
  cursor: pointer;
  line-height: 1.2;
  flex-shrink: 0;
}

.ls-memperson-row-backfill:hover {
  background: #dcfce7;
}

.ls-memmeta-row .ls-memperson-row-backfill {
  border-color: #4ade80;
}

.ls-memperson-row-name {
  font-weight: 600;
  color: #1f2937;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ls-memperson-row-status {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
}

.ls-memperson-row-meta-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ls-memperson-row-meta {
  font-size: 10px;
  color: #64748b;
  line-height: 1.35;
  word-break: break-word;
}

.ls-mempersons-modal .ls-mempersons-modal-panel {
  width: min(92vw, 640px);
  min-height: min(52vh, 520px);
  max-height: min(88vh, 900px);
}

.ls-mempersons-modal-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fafafa;
  border-top: 1px solid #e2e8f0;
}

.ls-mempersons-modal-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px 14px;
  background: #fff;
}

/* Footer strip below enlarged list — stays visible while list scrolls. */
.ls-mempersons-modal-merge-bar {
  flex-shrink: 0;
  margin-top: 0;
  background: #fff;
}

.ls-mempersons-modal-list .ls-memperson-row {
  margin-bottom: 8px;
}

.ls-mempersons-modal-list .ls-memperson-row-meta {
  font-size: 11px;
}

/* Provisional rows read softer than promoted/active memPerson cards. */
.ls-mempersons-modal-list .ls-memperson-row.ls-memperson-row-provisional {
  background: #f4f4f6;
  border-color: #e4e4e8;
}

.ls-mempersons-modal-list .ls-memperson-row.ls-memperson-row-provisional:hover {
  background: #ebebef;
  border-color: #d9d9df;
}

.ls-mempersons-modal-list .ls-memperson-row.ls-memperson-row-provisional .ls-memperson-row-name {
  color: #52525b;
}

/* Same small grey treatment as Transcripts catalog (`.ls-tr-row-meta`). */
.ls-tr-row-meta,
.ls-mem-row-meta {
  font-size: 10px;
  color: #888;
  margin-top: 4px;
}

.ls-mem-row-subject {
  font-size: 10px;
  color: #64748b;
  margin-top: 4px;
  word-break: break-word;
}

.ls-modal-subject-identity {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 10px;
  word-break: break-word;
}

.ls-modal-subject-tokens {
  margin-bottom: 6px;
}

.ls-modal-subject-persons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  line-height: 1.45;
}

.ls-modal-memperson-link {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #3730a3;
  cursor: pointer;
  max-width: 100%;
}

.ls-modal-memperson-link:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
}

@keyframes ls-memperson-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
  12% {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

.ls-memperson-row-flash {
  animation: ls-memperson-flash 2s ease-out 1;
}

.ls-mem-row-del {
  flex-shrink: 0;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
}

.ls-mem-row-del:hover {
  background: #fee2e2;
  border-color: #fecaca;
}

.ls-mem-row-redo {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  cursor: pointer;
}

.ls-mem-row-redo:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.ls-mem-no-ts {
  flex-shrink: 0;
  align-self: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #fdba74;
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  color: #c2410c;
}

.ls-tr-row-main {
  flex: 1;
  min-width: 0;
}

.ls-tr-row-del {
  flex-shrink: 0;
  align-self: flex-start;
  font-size: 12px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
}

.ls-tr-row-del:hover {
  background: #fee2e2;
  border-color: #fecaca;
}

/* Modal */
.ls-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  /* Above .ls-triple-modal (1200) so transcript/memSum opened from the graph inspector stack on top */
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.ls-modal-backdrop[hidden] {
  display: none;
}

/* memPerson profile / memMeta inspector: above memPersons list modal (1350) when both are open */
.ls-modal-backdrop.ls-modal-memperson-detail,
.ls-modal-backdrop.ls-modal-mem-meta {
  z-index: 1400;
}

.ls-modal {
  background: #fff;
  border-radius: 14px;
  max-width: min(920px, 96vw);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
  min-width: min(400px, 96vw);
}

.ls-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
}

.ls-modal-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.ls-modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  padding: 0 4px;
}

.ls-modal-close:hover {
  color: #0f172a;
}

.ls-modal-stack {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ls-modal-transcript-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 16px 10px;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}

/* [hidden] must win: the flex rule above otherwise keeps the strip visible for memStory/memSum modals. */
.ls-modal-transcript-toolbar[hidden] {
  display: none !important;
}

/* Sliding pill: one thumb, two modes (matches native segmented control feel). */
.ls-tr-view-toggle {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  background: #e2e8f0;
  border-radius: 999px;
  padding: 2px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}

.ls-tr-view-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(50% - 2px);
  height: calc(100% - 4px);
  background: #0f172a;
  border-radius: 999px;
  transition: transform 0.18s ease;
  pointer-events: none;
  z-index: 0;
}

.ls-tr-view-toggle.ls-tr-view-toggle--rendered .ls-tr-view-thumb {
  transform: translateX(100%);
}

.ls-tr-view-btn {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  color: #64748b;
  border-radius: 999px;
  transition: color 0.15s ease;
}

.ls-tr-view-btn:hover {
  color: #0f172a;
}

.ls-tr-view-toggle.ls-tr-view-toggle--raw .ls-tr-view-btn[data-transcript-view="raw"],
.ls-tr-view-toggle.ls-tr-view-toggle--rendered .ls-tr-view-btn[data-transcript-view="rendered"] {
  color: #fff;
}

.ls-tr-view-toggle.ls-tr-view-toggle--raw .ls-tr-view-btn[data-transcript-view="raw"]:hover,
.ls-tr-view-toggle.ls-tr-view-toggle--rendered .ls-tr-view-btn[data-transcript-view="rendered"]:hover {
  color: #fff;
}

.ls-modal-body {
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  flex: 1;
  min-height: 0;
  word-break: break-word;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

.ls-modal-pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
  color: #1e293b;
}

.ls-modal-memperson-meta {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 10px;
  word-break: break-word;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ls-modal-memperson-meta-row {
  line-height: 1.45;
}

.ls-modal-memperson-profile-pre {
  max-height: min(70vh, 560px);
  overflow: auto;
}

.ls-modal-memmeta-section-block {
  margin: 0 0 10px;
  font-size: 12px;
}

.ls-modal-memmeta-section-title {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ls-modal-memmeta-section-list {
  margin: 0 0 0 1.1em;
  padding: 0;
  color: #334155;
  line-height: 1.4;
}

.ls-modal-memmeta-pre {
  max-height: min(50vh, 420px);
  overflow: auto;
  margin-top: 8px;
  font-size: 11px;
}

.ls-memmeta-modal-bar {
  margin-bottom: 8px;
}

/* memPerson detail: reserve readable space for the dossier when it has content; contributing
   memSums live in the footer and can otherwise shrink the body to nothing. */
.ls-modal-backdrop.ls-modal-memperson-detail .ls-modal-stack {
  min-height: min(200px, 36vh);
}

.ls-modal-backdrop.ls-modal-memperson-detail .ls-modal-memperson-profile-pre--filled {
  min-height: min(200px, 36vh);
  box-sizing: border-box;
}

.ls-modal-backdrop.ls-modal-memperson-detail .ls-modal-influences {
  max-height: min(30vh, 260px);
  overflow-y: auto;
}

.ls-modal-edit-text {
  width: 100%;
  min-height: min(56vh, 560px);
  box-sizing: border-box;
  resize: vertical;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
  color: #1e293b;
  background: #fff;
}

.ls-modal-edit-text:focus {
  outline: 2px solid rgba(37, 99, 235, 0.22);
  border-color: #60a5fa;
}

/* Match .ls-modal-pre exactly so toggling Raw/Rendered does not resize the modal body. */
.ls-tr-render {
  margin: 0;
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
  color: #1e293b;
}

.ls-tr-line {
  margin: 0;
  padding: 0;
  min-height: 1.4em;
}

.ls-tr-line.ls-tr-blank {
  min-height: 1.4em;
}

.ls-tr-msg .ls-tr-actor {
  font-weight: 600;
  color: #334155;
}

.ls-tr-msg .ls-tr-text {
  white-space: pre-wrap;
  color: #1e293b;
}

.ls-tr-remember {
  color: #475569;
}

.ls-tr-remember i {
  font-style: italic;
  color: #64748b;
}

.ls-tr-expectation {
  color: #0f766e;
}

.ls-tr-expectation-label {
  font-weight: 600;
}

.ls-tr-action {
  color: #4338ca;
}

.ls-tr-action-label {
  font-weight: 600;
}

.ls-tr-fallback {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  color: #64748b;
  white-space: pre-wrap;
}

.ls-modal-footer {
  padding: 10px 16px 14px;
  border-top: 1px solid #eee;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.ls-modal-links {
  font-size: 12px;
  line-height: 1.45;
}

.ls-modal-links[hidden] {
  display: none !important;
}

.ls-modal-influences {
  font-size: 12px;
  line-height: 1.45;
  padding-top: 4px;
}

.ls-modal-influences[hidden] {
  display: none !important;
}

.ls-modal-influences-head {
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.ls-modal-influences-line {
  display: block;
  line-height: 1.55;
  word-break: break-word;
}

.ls-modal-influences-empty {
  color: #94a3b8;
  font-style: italic;
}

.ls-modal-link {
  display: inline;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: #2563eb;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  font: inherit;
}

.ls-modal-link:hover {
  color: #1d4ed8;
}

.ls-modal-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ls-modal-edit,
.ls-modal-edit-cancel {
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.ls-modal-edit {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.ls-modal-edit:hover {
  background: #dbeafe;
}

.ls-modal-edit-cancel {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
}

.ls-modal-edit-cancel:hover {
  background: #f1f5f9;
}

.ls-modal-delete {
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  cursor: pointer;
}

.ls-modal-delete:hover {
  background: #fee2e2;
}

.ls-modal-redo {
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #166534;
  cursor: pointer;
}

.ls-modal-redo:hover {
  background: #dcfce7;
}

.ls-assoc-section {
  position: relative;
}

.ls-assoc-toggle-wrap {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 2;
}

.ls-assoc-toggle-btn {
  font-size: 11px;
  padding: 4px 9px;
}

.ls-memstories-section,
.ls-memperson-profiles-section {
  position: relative;
}

.ls-memstories-toggle-wrap {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: min(420px, 100%);
}

.ls-memstories-toggle-btn {
  font-size: 11px;
  padding: 4px 9px;
}

.ls-memsums-section {
  position: relative;
}

.ls-memsums-toggle-wrap {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 2;
}

.ls-memsums-toggle-btn {
  font-size: 11px;
  padding: 4px 9px;
}

.ls-transcripts-section {
  position: relative;
}

.ls-transcripts-toggle-wrap {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 2;
}

.ls-transcripts-toggle-btn {
  font-size: 11px;
  padding: 4px 9px;
}

.ls-cost-panel {
  flex-shrink: 0;
  padding: 6px 12px 8px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  font-size: 11px;
  color: #444;
}

.ls-cost-heading {
  font-weight: 600;
  font-size: 12px;
  color: #222;
  margin-bottom: 3px;
}

.ls-cost-model-tiers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 8px;
  margin-bottom: 4px;
  font-size: 10px;
}

@media (max-width: 900px) {
  .ls-cost-model-tiers {
    grid-template-columns: 1fr;
  }
}

.ls-cost-model-tier {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.ls-cost-model-tier label {
  flex: 0 0 auto;
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
}

.ls-cost-model-tier select {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 10px;
  padding: 1px 2px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  color: #1e293b;
}

.ls-cost-tier-hint {
  font-size: 10px;
  color: #64748b;
  line-height: 1.25;
}

.ls-cost-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.28;
  margin-bottom: 5px;
  word-break: break-all;
}

.ls-cost-counters {
  margin-top: 0;
  font-size: 10px;
  color: #475569;
}

.ls-cost-rates {
  font-size: 10px;
  color: #64748b;
  line-height: 1.25;
}

.ls-cost-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-items: start;
}

@media (max-width: 1100px) {
  .ls-cost-charts-row {
    grid-template-columns: 1fr;
  }
}

.ls-cost-chart-cell {
  min-width: 0;
}

.ls-cost-chart-label {
  font-size: 10px;
  color: #64748b;
  margin-bottom: 2px;
  font-weight: 600;
}

.ls-cost-chart-wrap {
  height: 52px;
}

.ls-cost-turn-block {
  margin-top: 5px;
}

.ls-cost-turn-wrap {
  padding: 5px 8px;
  background: #fafafa;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.ls-cost-turn-metrics {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: #334155;
}

.ls-cost-turn-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.ls-cost-turn-k {
  color: #64748b;
  font-weight: 600;
  font-size: 11px;
}

.ls-cost-turn-v {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #1e293b;
}

.ls-cost-turn-hint {
  margin-top: 4px;
  font-size: 9px;
  color: #94a3b8;
  line-height: 1.25;
}

.ls-cost-turn-note {
  margin-top: 4px;
  font-size: 10px;
  color: #64748b;
  line-height: 1.3;
}

.ls-cost-turn-empty {
  color: #888;
  padding: 4px 0 2px;
  text-align: center;
  font-size: 11px;
}

.ls-cost-chart-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ls-cost-empty {
  color: #888;
  padding: 4px 0;
  text-align: center;
  font-size: 10px;
}

.ls-cost-warn {
  color: #b45309;
}

.ls-cost-tool {
  margin-top: 1px;
  font-size: 10px;
  color: #666;
}

.ls-chat-panel {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.2);
}

@keyframes ls-chat-panel-session-glow {
  0%,
  100% {
    box-shadow:
      0 2px 12px rgba(59, 130, 246, 0.2),
      0 0 0 2px rgba(59, 130, 246, 0.28),
      0 0 24px rgba(59, 130, 246, 0.18);
  }
  50% {
    box-shadow:
      0 2px 12px rgba(59, 130, 246, 0.2),
      0 0 0 2px rgba(37, 99, 235, 0.55),
      0 0 48px rgba(59, 130, 246, 0.42),
      0 0 72px rgba(37, 99, 235, 0.16);
  }
}

.ls-chat-panel--in-session {
  animation: ls-chat-panel-session-glow 4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .ls-chat-panel--in-session {
    animation: none;
    box-shadow:
      0 2px 12px rgba(59, 130, 246, 0.2),
      0 0 0 2px rgba(59, 130, 246, 0.45),
      0 0 32px rgba(59, 130, 246, 0.28);
  }
}

.ls-chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}

.ls-chat-panel-head h2 {
  margin: 0;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

.ls-chat-panel-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ls-chat-debug-toggle {
  flex-shrink: 0;
  margin: 0;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #37474f;
  background: #eceff1;
  border: 1px solid #cfd8dc;
  border-radius: 999px;
  cursor: pointer;
}

.ls-chat-debug-toggle:hover {
  background: #e1e6ea;
}

.ls-chat-debug-toggle[aria-pressed="true"] {
  background: #e3f2fd;
  border-color: #90caf9;
  color: #1565c0;
}

.ls-chat-off-record-toggle[aria-pressed="false"] {
  background: #fff3e0;
  border-color: #ffcc80;
  color: #e65100;
}

.ls-chat-panel.ls-chat-debug-off #messageList .ls-msg-row--event {
  display: none;
}

#messageList {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ls-msg-row {
  display: flex;
  width: 100%;
}

.ls-msg-row--user {
  justify-content: flex-end;
}

.ls-msg-row--assistant,
.ls-msg-row--event {
  justify-content: flex-start;
}

.ls-msg-bubble {
  max-width: min(88%, 440px);
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.ls-msg-bubble--user {
  background: #0b84ff;
  color: #fff;
  border-bottom-right-radius: 6px;
}

.ls-msg-bubble--assistant {
  background: #d8f3dc;
  color: #14532d;
  border: 1px solid #95d5b2;
  border-bottom-left-radius: 6px;
}

.ls-msg-bubble--event {
  background: #eceff1;
  color: #37474f;
  border: 1px solid #cfd8dc;
  border-bottom-left-radius: 6px;
}

.ls-msg-bubble--user .ls-msg-role {
  color: rgba(255, 255, 255, 0.82);
}

.ls-msg-bubble--assistant .ls-msg-role,
.ls-msg-bubble--event .ls-msg-role {
  color: #546e7a;
}

.ls-msg-role {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  margin-bottom: 6px;
}

.ls-msg-body {
  font-size: 13px;
}

.ls-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #eee;
}

.ls-input-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 10px;
  font-size: 14px;
}

.ls-input-row button {
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  background: #007aff;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.ls-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
}

.ls-section {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  overflow: visible;
}

.ls-section summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 12px;
  background: #fafafa;
  border-bottom: 1px solid #eee;
  list-style: none;
  border-radius: 12px 12px 0 0;
}

.ls-section summary::-webkit-details-marker {
  display: none;
}

details.ls-section:not([open]) > summary {
  border-radius: 12px;
  border-bottom: none;
}

/* Scrollable (and vertically resizable) context bodies — cap height by viewport; drag corner to resize */
.ls-section .ls-body {
  padding: 10px 14px;
  font-size: 11px;
  min-height: 5em;
  max-height: min(85vh, 1400px);
  overflow-y: auto;
  overflow-x: auto;
  resize: vertical;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: #222;
  border-radius: 0 0 12px 12px;
  box-sizing: border-box;
}

/* Right column: compact collapsible panels (no context-body min-height / resize) */
.ls-right-column .ls-section .ls-group-create-body,
.ls-right-column .ls-section .ls-identity-section-body {
  padding: 0;
  min-height: 0;
  max-height: none;
  overflow: visible;
  resize: none;
  white-space: normal;
}

.ls-right-column .ls-section summary {
  padding: 8px 12px;
}

.ls-agent-personas-panel {
  flex: 0 0 auto;
  min-height: 0;
  height: auto;
  overflow: visible;
}

.ls-agent-personas-panel .ls-panel-head {
  padding: 4px 10px;
  font-size: 11px;
}

.ls-agent-personas-panel .ls-panel-refresh {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 6px;
}

.ls-agent-personas-list {
  flex: 0 0 auto;
  min-height: 0;
  max-height: min(18vh, 112px);
  overflow-y: auto;
  padding: 2px 6px 3px;
}

.ls-agent-persona-row:last-child {
  margin-bottom: 0;
}

.ls-agent-persona-row {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 2px 6px;
  margin: 0 4px 3px;
  background: #fff;
}

.ls-agent-persona-row-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ls-agent-persona-row:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.ls-agent-persona-row-active {
  border-color: #4ade80;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 55%, #f8fafc 100%);
}

.ls-agent-persona-row-active:hover {
  border-color: #22c55e;
  background: linear-gradient(135deg, #dcfce7 0%, #ecfdf5 55%, #f1f5f9 100%);
}

.ls-agent-persona-row-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 0 1 auto;
}

.ls-agent-persona-row-name {
  font-weight: 600;
  font-size: 11px;
  line-height: 1.2;
  color: #1f2937;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ls-agent-persona-row-activate {
  flex-shrink: 0;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  cursor: pointer;
  line-height: 1.2;
}

.ls-agent-persona-row-activate:hover:not(:disabled) {
  border-color: #94a3b8;
  background: #f8fafc;
}

.ls-agent-persona-row-activate:disabled {
  opacity: 1;
  cursor: default;
  color: #15803d;
  font-weight: 600;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.ls-agent-persona-row-meta {
  font-size: 9px;
  color: #64748b;
  margin-top: 0;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ls-active-inputs-panel {
  flex: 0 0 auto;
}

.ls-active-inputs-body {
  padding: 6px 10px 10px;
  font-size: 11px;
  line-height: 1.45;
  color: #334155;
}

.ls-active-inputs-empty {
  margin: 0;
  color: #94a3b8;
  font-size: 11px;
}

.ls-active-inputs-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}

.ls-active-input-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 10px;
  line-height: 1.35;
  min-width: 0;
}

.ls-active-input-pill-label {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.ls-active-input-pill-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #0f172a;
}

.ls-active-input-pill--user {
  padding: 1px 5px;
  font-size: 8px;
  line-height: 1.2;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.ls-active-input-pill--user .ls-active-input-pill-label {
  font-size: 7px;
  color: #1d4ed8;
}

.ls-active-input-pill--user .ls-active-input-pill-value {
  font-size: 8px;
  font-family: inherit;
  font-weight: 600;
  color: #1e3a8a;
}

.ls-active-input-pill--mem {
  padding: 1px 5px;
  font-size: 8px;
  line-height: 1.2;
  border-color: #ddd6fe;
  background: #f5f3ff;
}

.ls-active-input-pill--mem .ls-active-input-pill-label {
  font-size: 7px;
  color: #6d28d9;
}

.ls-active-input-pill--mem .ls-active-input-pill-value {
  font-size: 8px;
  font-family: inherit;
  font-weight: 600;
  color: #5b21b6;
}

.ls-active-input-pill--see-fen,
.ls-active-input-pill--see-move,
.ls-active-input-pill--see-vision,
.ls-active-input-pill[class*="ls-active-input-pill--see-"] {
  padding: 1px 5px;
  font-size: 8px;
  line-height: 1.2;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.ls-active-input-pill--see-fen .ls-active-input-pill-label,
.ls-active-input-pill--see-move .ls-active-input-pill-label,
.ls-active-input-pill--see-vision .ls-active-input-pill-label,
.ls-active-input-pill[class*="ls-active-input-pill--see-"] .ls-active-input-pill-label {
  font-size: 7px;
  color: #15803d;
}

.ls-active-input-pill--see-fen .ls-active-input-pill-value,
.ls-active-input-pill--see-move .ls-active-input-pill-value,
.ls-active-input-pill--see-vision .ls-active-input-pill-value,
.ls-active-input-pill[class*="ls-active-input-pill--see-"] .ls-active-input-pill-value {
  font-size: 8px;
  font-family: inherit;
  font-weight: 600;
  color: #166534;
}

.ls-active-input-pill--see-vision {
  border-color: #fde68a;
  background: #fffbeb;
}

.ls-active-input-pill--see-vision .ls-active-input-pill-label {
  color: #b45309;
}

.ls-active-input-pill--see-vision .ls-active-input-pill-value {
  color: #92400e;
}

.ls-agent-persona-modal-panel {
  width: min(720px, 92vw);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
}

.ls-agent-persona-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ls-agent-persona-modal-hint {
  font-size: 11px;
  color: #64748b;
  margin: 0;
  line-height: 1.45;
}

.ls-agent-persona-modal-text {
  flex: 1 1 auto;
  min-height: 280px;
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  resize: vertical;
  box-sizing: border-box;
}

.ls-agent-persona-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px 16px;
  border-top: 1px solid #eee;
}

.ls-identity-section-body > .ls-name-resolution-actions:last-child {
  border-top: 1px solid #eee;
  padding-top: 6px;
  padding-bottom: 10px;
}

/* Associative Triples section: color provenance kind (see triple_context _provenance_tail_for_ui) */
.ls-assoc-context {
  display: block;
}
.ls-assoc-line {
  display: block;
  margin: 0 0 0.28em;
}
.ls-assoc-line:last-child {
  margin-bottom: 0;
}
.ls-assoc-token-legend {
  display: block;
  margin: 0 0 6px;
  font-size: 10px;
  color: #1d4ed8;
}

.ls-assoc-token-legend-prediction {
  color: #be185d;
}

.ls-assoc-token-legend-semantic {
  color: #c2410c;
}

.ls-assoc-token-legend-kinship {
  color: #0f766e;
}

.ls-assoc-token-note {
  margin: 0 0 6px;
  font-size: 9px;
  line-height: 1.2;
  color: #64748b;
}

.ls-memory-mode-row {
  margin-bottom: 8px;
}

.ls-memory-mode-row:last-child {
  margin-bottom: 0;
}

.ls-memory-mode-title {
  font-size: 10px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 2px;
}

.ls-memory-mode-selected {
  color: #1d4ed8;
}

/* Carryover recall only — softer blue vs current-turn overlap bullets */
.ls-memory-mode-decayed {
  color: #93c5fd;
}

.ls-memory-mode-story-body .ls-memory-bullet-block {
  margin-bottom: 6px;
}

.ls-memory-mode-story-body .ls-memory-bullet-block:last-child {
  margin-bottom: 0;
}

.ls-memory-mode-fallback {
  color: #374151;
}
.ls-assoc-token {
  border-radius: 4px;
  padding: 0 2px;
  font-weight: 600;
}
.ls-assoc-token-current {
  background: #dcfce7;
  color: #15803d;
}
.ls-assoc-token-assistant {
  background: #e0f2fe;
  color: #0369a1;
}
.ls-assoc-token-legend-assistant .ls-assoc-token-assistant {
  background: #e0f2fe;
  color: #0369a1;
}
.ls-assoc-token-feedback {
  background: #e0e7ff;
  color: #4338ca;
}
.ls-assoc-token-focus {
  background: #dbeafe;
  color: #1d4ed8;
}
.ls-assoc-token-memperson {
  background: #e0e7ff;
  color: #3730a3;
}
.ls-assoc-token-prediction {
  background: #fce7f3;
  color: #be185d;
}
.ls-assoc-token-semantic {
  background: #ffedd5;
  color: #c2410c;
}
.ls-assoc-token-legend-semantic .ls-assoc-token-semantic {
  background: #ffedd5;
  color: #c2410c;
}
.ls-assoc-token-kinship {
  background: #ccfbf1;
  color: #0f766e;
}
.ls-assoc-token-legend-kinship .ls-assoc-token-kinship {
  background: #ccfbf1;
  color: #0f766e;
}
.ls-section .ls-body .ls-assoc-context span.ls-prov-memstory {
  color: #0d9488;
  font-weight: 600;
}
.ls-section .ls-body .ls-assoc-context span.ls-prov-memsum {
  color: #2563eb;
  font-weight: 600;
}
.ls-section .ls-body .ls-assoc-context span.ls-prov-transcript {
  color: #000;
  font-weight: 600;
}

.ls-section.ls-wide .ls-body {
  max-height: min(88vh, 1600px);
}

.ls-timeline .ls-body {
  font-family: ui-monospace, monospace;
  max-height: min(80vh, 1400px);
}

/* Story entries inside Saved Stories (nested details) */
.ls-stories-list details > div:last-child {
  max-height: min(55vh, 720px);
  overflow-y: auto;
  overflow-x: auto;
  overflow-wrap: anywhere;
  scrollbar-gutter: stable;
}

.ls-tl-line {
  margin-bottom: 6px;
  border-bottom: 1px dashed #eee;
  padding-bottom: 4px;
}

.ls-stories-list details {
  margin-bottom: 8px;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 6px 8px;
}

.ls-stories-list summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}

.ls-meta {
  font-size: 10px;
  color: #888;
  margin-top: 4px;
}

.ls-story-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 4px 14px 0;
}

.ls-story-delete {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #fafafa;
  color: #333;
  cursor: pointer;
}

.ls-story-delete:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.ls-top-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
  padding: 10px 16px;
  gap: 12px;
  min-height: 3rem;
}

.ls-status {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ls-brand {
  flex: 0 0 auto;
  margin-left: auto;
  text-align: right;
  font-size: clamp(1rem, 5vw, 1.25rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #0f172a;
  white-space: nowrap;
  line-height: 1.05;
}

.ls-user-panel {
  flex: 0 0 auto;
}

.ls-user-panel-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 12px;
}

.ls-user-panel-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.ls-user-panel-actions select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #ddd;
  font-size: 12px;
  background: #fff;
  color: #0f172a;
}

.ls-user-panel-actions input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #ddd;
  font-size: 12px;
}

.ls-user-panel-actions button {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  background: #475569;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.ls-user-panel-actions button:hover {
  background: #334155;
}

.ls-user-panel-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Expectation panel: prior-turn seed overlap debug (lab-ui.js) */
.ls-expectation-seed-debug {
  margin-top: 8px;
  font-size: 10px;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.ls-expectation-seed-cand-title {
  font-size: 9px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 4px;
}

.ls-expectation-seed-candidates {
  display: block;
  margin-bottom: 8px;
}

.ls-expectation-seed-candidates .ls-expectation-seed-cand-used {
  color: #15803d;
  font-weight: 600;
}

.ls-expectation-seed-candidates .ls-expectation-seed-cand-other {
  color: #475569;
}

.ls-expectation-seed-cand-empty {
  color: #94a3b8;
}

.ls-expectation-seed-unused-title {
  font-size: 9px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 2px;
}

.ls-expectation-seed-unused-list {
  color: #64748b;
}

