.conversation-memory-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: stretch;
  justify-content: stretch;
  background: rgba(2, 6, 23, .88);
  backdrop-filter: blur(4px);
}

.conversation-memory-modal.open { display: flex; }

.conversation-memory-dialog {
  display: flex;
  flex-direction: column;
  width: calc(100% - 48px);
  height: calc(100% - 48px);
  margin: 24px;
  overflow: hidden;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .48);
}

.conversation-memory-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 18px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
}

.conversation-memory-header h2 {
  margin: 0;
  color: #f8fafc;
  font-size: 1.05rem;
}

.conversation-memory-header .memory-meta {
  color: #64748b;
  font-size: .76rem;
}

.conversation-memory-header button,
.conversation-memory-action {
  padding: 6px 10px;
  color: #cbd5e1;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 6px;
  cursor: pointer;
}

.conversation-memory-header button:hover,
.conversation-memory-action:hover:not(:disabled) {
  color: #fff;
  background: #334155;
}

.conversation-memory-header button:disabled,
.conversation-memory-action:disabled { opacity: .45; cursor: wait; }
.conversation-memory-header .memory-close { margin-left: auto; }
.conversation-memory-action.danger { color: #fca5a5; border-color: #7f1d1d; }
.conversation-memory-action.danger:hover:not(:disabled) { background: #7f1d1d; }

.conversation-memory-body {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 330px;
  flex: 1;
  min-height: 0;
}

.conversation-memory-sidebar,
.conversation-memory-inspector,
.conversation-memory-memories {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.conversation-memory-sidebar {
  background: #172033;
  border-right: 1px solid #334155;
}

.conversation-memory-memories {
  background: #172033;
  border-left: 1px solid #334155;
}

.memory-section-title {
  margin: 0 0 10px;
  color: #94a3b8;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.memory-diagnostics {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #334155;
  background: #111b2e;
}

.memory-diagnostic {
  min-width: 0;
  padding: 8px 10px;
  background: #0f172a;
  border: 1px solid #293548;
  border-radius: 7px;
}

.memory-diagnostic small { display: block; color: #64748b; font-size: .68rem; }
.memory-diagnostic strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #7dd3fc;
  font-size: .78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-transition {
  padding: 7px 14px;
  color: #a5b4fc;
  background: #172033;
  border-bottom: 1px solid #334155;
  font-size: .74rem;
}

.memory-session-button {
  display: block;
  width: 100%;
  margin-bottom: 7px;
  padding: 9px 10px;
  color: #cbd5e1;
  background: #0f172a;
  border: 1px solid #293548;
  border-radius: 7px;
  text-align: left;
  cursor: pointer;
}

.memory-session-button:hover { border-color: #475569; }
.memory-session-button.active { color: #e0f2fe; background: #1e3a5f; border-color: #0369a1; }
.memory-session-button.current::before { content: '当前 · '; color: #34d399; font-size: .7rem; }
.memory-session-button code { display: block; overflow: hidden; text-overflow: ellipsis; }
.memory-session-button small { display: block; margin-top: 4px; color: #64748b; }

.memory-empty {
  padding: 28px 12px;
  color: #64748b;
  font-size: .8rem;
  text-align: center;
}

.memory-summary {
  margin-bottom: 12px;
  padding: 11px 12px;
  color: #cbd5e1;
  background: #172033;
  border: 1px solid #334155;
  border-radius: 8px;
  font-size: .8rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.memory-summary strong { display: block; margin-bottom: 5px; color: #7dd3fc; }
.memory-summary small { display: block; margin-top: 6px; color: #64748b; }

.memory-turn {
  margin-bottom: 10px;
  padding: 10px 12px;
  background: #111b2e;
  border: 1px solid #293548;
  border-radius: 8px;
}

.memory-turn-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: #64748b;
  font-size: .7rem;
}

.memory-turn-header .turn-status { margin-left: auto; }
.turn-status.completed { color: #34d399; }
.turn-status.processing { color: #fbbf24; }
.turn-status.failed, .turn-status.degraded, .turn-status.interrupted { color: #fca5a5; }
.memory-turn-message { margin-top: 5px; color: #cbd5e1; font-size: .8rem; line-height: 1.48; white-space: pre-wrap; word-break: break-word; }
.memory-turn-message b { color: #94a3b8; }

.memory-item {
  margin-bottom: 8px;
  padding: 9px 10px;
  color: #cbd5e1;
  background: #0f172a;
  border: 1px solid #293548;
  border-radius: 7px;
  font-size: .78rem;
  line-height: 1.45;
}

.memory-item small { display: block; margin-top: 5px; color: #64748b; word-break: break-all; }
.memory-seed { margin-top: 16px; padding-top: 12px; border-top: 1px solid #334155; }
.memory-seed textarea {
  width: 100%;
  min-height: 105px;
  padding: 8px 9px;
  color: #cbd5e1;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 7px;
  resize: vertical;
  font: inherit;
  font-size: .76rem;
  line-height: 1.45;
}
.memory-seed .conversation-memory-action { width: 100%; margin-top: 7px; }
.memory-seed-hint { margin-top: 6px; color: #64748b; font-size: .68rem; line-height: 1.4; }
.memory-error { margin: 16px; padding: 12px; color: #fca5a5; background: #450a0a; border-radius: 7px; }

@media (max-width: 1050px) {
  .conversation-memory-body { grid-template-columns: 220px minmax(0, 1fr); }
  .conversation-memory-memories { grid-column: 1 / -1; max-height: 280px; border-top: 1px solid #334155; border-left: 0; }
  .memory-diagnostics { grid-template-columns: repeat(3, minmax(110px, 1fr)); }
}

@media (max-width: 720px) {
  .conversation-memory-dialog { width: 100%; height: 100%; margin: 0; border-radius: 0; }
  .conversation-memory-body { display: block; overflow: auto; }
  .conversation-memory-sidebar, .conversation-memory-inspector, .conversation-memory-memories { overflow: visible; border: 0; border-bottom: 1px solid #334155; }
  .memory-diagnostics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
