/* ===== Memories Panel ===== */

/* Header */
#edit_character_memories-panel .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

#edit_character_memories-title {
  flex: 1 1 160px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#edit_character_memories-header-tools {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

#edit_character_memories-search-shell {
  width: 0;
  min-width: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: width 160ms ease, opacity 160ms ease;
}

#edit_character_memories-header-tools.search-open #edit_character_memories-search-shell {
  width: min(220px, 38vw);
  opacity: 1;
  pointer-events: auto;
}

#edit_character_memories-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.92);
  color: #374151;
  font-size: 14px;
  outline: none;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.75);
}

#edit_character_memories-search-input:focus {
  border-color: rgba(236, 72, 153, 0.38);
  box-shadow:
    0 0 0 3px rgba(236, 72, 153, 0.14),
    inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

#edit_character_memories-panel .panel-header .btn-panel-header {
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
}

/* Layout: list scrolls, composer sticks to bottom */
#edit_character_memories-panel .panel-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 420px;    /* safety */
  overflow: hidden;     /* only the list scrolls */
}

/* ===== List (scrolling area) ===== */
#edit_character_memories-list {
  list-style: none;
  padding: 12px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;       /* fills remaining space */
  overflow-y: auto;     /* scroll here */
}

#edit_character_memories-list.search-active {
  padding-top: 8px;
}

/* Each item centered */
#edit_character_memories-list .memory-item {
  display: flex;
  justify-content: center;      /* center bubble horizontally */
  padding: 0;
  position: relative;
  transition: opacity 180ms ease, transform 180ms ease;
  border: 0;
}
#edit_character_memories-list .memory-item.removing { opacity: 0; transform: translateY(-4px); }
#edit_character_memories-list .memory-item.ghost    { opacity: 0.7; }

#edit_character_memories-list .memory-window-status {
  text-align: center;
  font-size: 12px;
  color: #6b7280;
  padding: 2px 0 8px;
}

/* Container around the bubble (no sizing here) */
#edit_character_memories-list .memory-entry { /* intentionally empty */ }

/* ===== Bubble (compact) ===== */
#edit_character_memories-list .memory-bubble {
  position: relative;
  display: inline-block;        /* shrink-to-fit */
  max-width: min(720px, 90%);   /* sensible cap */
  background: #f5f7fb;
  background-image: linear-gradient(#ffffff, #f6f8ff);
  border: 1px solid #0001;
  border-radius: 16px;
  padding: 6px 30px 6px 10px;   /* compact padding (top/right/bottom/left) */
  box-shadow: 0 2px 8px #0001;
  line-height: 1.22;            /* compact line height */
  word-wrap: break-word;
  white-space: normal;          /* let inner text control line breaks */
  font-size: 0.96rem;           /* slightly smaller inside bubbles */
}

/* Inner spacing: remove default margins */
#edit_character_memories-list .mem-title,
#edit_character_memories-list .mem-text,
#edit_character_memories-list .memory-meta {
  margin: 0;
}

/* Title & meta (tiny spacing only when present) */
#edit_character_memories-list .mem-title {
  font-weight: 600;
  margin-bottom: 2px;
}
#edit_character_memories-list .memory-meta {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#edit_character_memories-list .mem-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: rgba(236, 72, 153, 0.12);
  color: #9d1b63;
}

/* Text preserves newlines without extra vertical space */
#edit_character_memories-list .mem-text {
  white-space: pre-line;        /* \n => line breaks */
  display: inline;              /* avoid block height expansion */
  padding: 0;                   /* guard against global padding */
}

/* Actions row below bubble, hidden until hover */
#edit_character_memories-list .memory-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;   /* or flex-start / center */
  gap: 6px;
  opacity: 0;                  /* hidden by default */
  transition: opacity 140ms ease;
}

/* Show when hovering the whole memory item */
#edit_character_memories-list .memory-item:hover .memory-actions {
  opacity: 1;
}

#edit_character_memories-list .memory-actions .panel-action-button {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 4px 10px rgba(15, 23, 42, 0.18);
}

/* ===== Compose bar (sticky bottom) ===== */
#edit_character_memories-compose {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#edit_character_memories-compose textarea {
  resize: none;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  min-height: 50px;
  font: inherit;
  width: 100%;
}

#edit_character_memories-compose button {
  padding: 8px 14px;
  border: none;
  border-radius: 4px;
  background: #0077cc;
  color: #fff;
  cursor: pointer;
}

#edit_character_memories-compose button:disabled {
  background: #aaa;
  cursor: not-allowed;
}

#edit_character_memories-compose .btn-red {
  background: #dc2626;
  color: #fff;
}

#edit_character_memories-compose .btn-red:hover {
  background: #b91c1c;
}

@media (max-width: 980px) {
  #edit_character_memories-panel .panel-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  #edit_character_memories-title {
    width: 100%;
    flex-basis: 100%;
  }

  #edit_character_memories-header-tools {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  #edit_character_memories-header-tools.search-open #edit_character_memories-search-shell {
    width: 100%;
  }
}

@media (max-width: 720px) {
  #edit_character_memories-panel .panel-header {
    align-items: flex-start;
  }

  #edit_character_memories-header-tools {
    gap: 6px;
  }

  #edit_character_memories-search-input {
    width: 100%;
    min-width: 0;
  }
}


.memory-bubble .edit-input {
  min-height: 40px;
  background: #fff;
  border-radius: 6px;
}
.edit-actions {
  margin-top: 4px;
}
.edit-actions button {
  margin-right: 4px;
}

/* highlight whole bubble when editing */
.memory-bubble.editing {
  outline: 2px solid #7fd6a7;         /* green outline */
  background-color: #e9f9ef;          /* light green background */
}

