.conversation-memory-host {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.agent-lab-conversation-tools {
  padding: 8px 0;
}

.cureqi-conversation-tools {
  padding: 8px 18px;
  border-bottom: 1px solid #edf0e7;
}

.conversation-tool-button,
.conversation-memory-dialog button {
  min-height: 40px;
  border: 1px solid currentColor;
  border-radius: 6px;
  padding: 8px 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: 0;
  cursor: pointer;
}

.conversation-tool-button:disabled,
.conversation-memory-dialog button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.conversation-memory-dialog {
  width: min(720px, calc(100vw - 32px));
  max-width: 720px;
  max-height: min(820px, calc(100dvh - 32px));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #b8b8b8;
  border-radius: 8px;
  background: #fff;
  color: #202020;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .24);
}

.conversation-memory-dialog::backdrop {
  background: rgba(0, 0, 0, .52);
}

.conversation-memory-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(820px, calc(100dvh - 32px));
}

.conversation-memory-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #dedede;
}

.conversation-memory-head h2,
.conversation-memory-body h3 {
  margin: 4px 0 0;
  font-size: 20px;
  line-height: 1.35;
  letter-spacing: 0;
}

.conversation-memory-body h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.conversation-memory-brand {
  color: #626262;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.conversation-memory-close {
  flex: 0 0 40px;
  width: 40px;
  padding: 0 !important;
  font-size: 24px !important;
  line-height: 1 !important;
}

.conversation-memory-body {
  min-width: 0;
  overflow: auto;
  padding: 18px 20px;
}

.conversation-memory-body p {
  margin: 0;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.conversation-memory-intro,
.conversation-memory-warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px !important;
}

.conversation-memory-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.conversation-memory-create-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.conversation-memory-warning {
  display: block;
  padding: 12px 14px;
  border-left: 3px solid #996d19;
  background: #fff8e8;
  color: #5f450f;
}

.conversation-memory-draft,
.conversation-memory-notes,
.conversation-share-preview,
.conversation-share-result {
  padding: 16px 0;
  border-top: 1px solid #dedede;
}

.conversation-memory-editor {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  font-weight: 600;
}

.conversation-memory-editor textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  resize: vertical;
  border: 1px solid #a9a9a9;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: #202020;
  font: inherit;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0;
}

.conversation-dialog-actions,
.conversation-export-actions,
.conversation-memory-note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.conversation-primary {
  border-color: #1f5d4f !important;
  background: #1f5d4f !important;
  color: #fff !important;
}

.conversation-secondary {
  border-color: #777 !important;
  color: #292929 !important;
}

.conversation-danger {
  border-color: #9b2f2f !important;
  color: #842626 !important;
}

.conversation-memory-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 16px;
  padding: 12px 0;
  border-top: 1px solid #ececec;
}

.conversation-memory-note:first-child {
  border-top: 0;
}

.conversation-memory-note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: #666;
  font-size: 12px;
}

.conversation-memory-note-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-content: start;
  margin-top: 0;
}

.conversation-share-turns {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.conversation-share-turns legend {
  margin-bottom: 10px;
  font-weight: 700;
}

.conversation-share-option {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid #ececec;
  cursor: pointer;
}

.conversation-share-option input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}

.conversation-share-option span {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.conversation-share-option small,
.conversation-muted {
  color: #666;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.conversation-share-preview-turn {
  padding: 12px 0;
  border-top: 1px solid #ececec;
}

.conversation-share-preview-turn strong,
.conversation-share-preview-turn small {
  display: block;
  margin: 7px 0 3px;
}

.conversation-share-link {
  display: block;
  margin-top: 8px;
  color: #145f8c;
  overflow-wrap: anywhere;
}

.conversation-memory-status {
  min-height: 22px;
  margin: 0;
  padding: 10px 20px 14px;
  border-top: 1px solid #dedede;
  color: #315c50;
  font-size: 13px;
  line-height: 1.5;
}

.conversation-memory-status[data-state="error"],
.conversation-error {
  color: #9b2f2f;
}

@media (max-width: 560px) {
  .conversation-memory-host {
    justify-content: stretch;
    width: 100%;
  }

  .agent-lab-conversation-tools,
  .cureqi-conversation-tools {
    padding: 8px 12px;
  }

  .conversation-tool-button {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 8px;
  }

  .conversation-memory-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .conversation-memory-shell {
    max-height: calc(100dvh - 16px);
  }

  .conversation-memory-head,
  .conversation-memory-body {
    padding-inline: 14px;
  }

  .conversation-memory-intro,
  .conversation-memory-note {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .conversation-memory-intro button,
  .conversation-export-actions button {
    width: 100%;
  }

  .conversation-memory-create-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .conversation-memory-note-actions {
    grid-column: 1;
    grid-row: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .conversation-memory-dialog * {
    scroll-behavior: auto !important;
  }
}
