/* ========== 11-memory.css ========== */
/* 記憶系統：統計、時間線、角色篩選、心情、照片上傳 */

.mem-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 16px 16px;
}

.mem-stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px solid #ececec;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .03);
}

.mem-stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f2f2f7;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mem-stat-num {
  font-size: 22px;
  font-weight: 700;
  color: #1d1d1f;
  letter-spacing: -.5px;
}

.mem-stat-label {
  font-size: 11px;
  color: #8e8e93;
  font-weight: 500;
}

/* ===== Timeline ===== */
.mem-timeline {
  margin: 0 16px;
  position: relative;
  padding-left: 20px;
}

.mem-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 1.5px;
  background: #e5e5ea;
}

.mem-tl-item {
  position: relative;
  margin-bottom: 16px;
}

.mem-tl-item::before {
  content: '';
  position: absolute;
  left: -17px;
  top: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c7c7cc;
  border: 2px solid #f2f2f7;
  z-index: 1;
}

.mem-tl-item:first-child::before {
  background: #1d1d1f;
}

.mem-tl-card {
  background: #fff;
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #ececec;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .04);
  cursor: pointer;
  transition: transform .12s;
}

.mem-tl-card:active {
  transform: scale(.98);
}

.mem-tl-photo {
  width: 100%;
  height: 140px;
  overflow: hidden;
}

.mem-tl-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mem-tl-body {
  padding: 14px 16px;
}

.mem-tl-title {
  font-size: 16px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 4px;
}

.mem-tl-text {
  font-size: 13px;
  color: #8e8e93;
  line-height: 1.4;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.mem-tl-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mem-tl-date {
  font-size: 11px;
  color: #c7c7cc;
  font-weight: 500;
}

/* ===== 统一胶囊标签 — 缩小 & 调淡 ===== */
/* 基础标签（通用） */
.mem-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: #f5f5f7;
  color: #8e8e93;
  line-height: 1.5;
  white-space: nowrap;
}

/* 情绪标签 */
.mem-tl-mood {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: #f5f5f7;
  color: #8e8e93;
  line-height: 1.5;
  white-space: nowrap;
}

/* 记忆类型标签（STM / LTM / Auto / merged） */
.mem-type-stm,
.mem-type-ltm,
.mem-type-manual,
.mem-type-auto {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: #f5f5f7;
  color: #8e8e93;
  line-height: 1.5;
  white-space: nowrap;
}

/* 角色标签（记忆列表） */
.mem-char-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: #f5f5f7;
  color: #8e8e93;
  line-height: 1.5;
  white-space: nowrap;
}

/* 收藏列表中的角色标签 */
.bk-char-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: #f5f5f7;
  color: #8e8e93;
  line-height: 1.5;
  white-space: nowrap;
}

.mem-empty {
  text-align: center;
  padding: 40px 30px;
  color: #8e8e93;
}

.mem-empty svg {
  display: block;
  margin: 0 auto 12px;
}

.mem-empty p {
  font-size: 14px;
  line-height: 1.6;
}

/* ===== Memory Edit ===== */
.mem-photo-upload {
  margin: 0 16px 16px;
  height: 160px;
  border-radius: 14px;
  background: #f2f2f7;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  border: 1.5px dashed #d1d1d6;
  transition: opacity .15s;
}

.mem-photo-upload:active {
  opacity: .7;
}

.mem-mood-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 16px 16px;
}

.mem-mood-tag {
  padding: 7px 16px;
  border-radius: 20px;
  background: #f2f2f7;
  border: 1.5px solid #e5e5ea;
  font-size: 13px;
  color: #3a3a3c;
  cursor: pointer;
  transition: all .2s;
  font-weight: 500;
}

.mem-mood-tag:active {
  opacity: .7;
}

.mem-mood-tag.selected {
  background: #1d1d1f;
  border-color: #1d1d1f;
  color: #fff;
}

.mem-date-header {
  padding: 16px 0 6px;
  font-size: 12px;
  color: #8e8e93;
  font-weight: 600;
  letter-spacing: .3px;
}

/* ===== Memory Char Filter ===== */
.mem-char-filter {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.mem-char-filter::-webkit-scrollbar {
  display: none;
}

.mem-char-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #fff;
  border: 1.5px solid #e5e5ea;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: #3a3a3c;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all .2s;
}

.mem-char-chip:active {
  opacity: .7;
}

.mem-char-chip.active {
  background: #1d1d1f;
  border-color: #1d1d1f;
  color: #fff;
}

.mem-char-chip .mcc-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  background: #e5e5ea;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mem-char-chip .mcc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mem-char-chip .mcc-avatar svg {
  width: 12px;
  height: 12px;
  stroke: #8e8e93;
  fill: none;
  stroke-width: 1.5;
}

.mem-char-chip.active .mcc-avatar {
  background: rgba(255, 255, 255, .15);
}

.mem-char-chip.active .mcc-avatar svg {
  stroke: rgba(255, 255, 255, .6);
}

.mem-char-info-card {
  margin: 0 16px 16px;
  background: linear-gradient(135deg, #f8f8fa, #f0f0f5);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid #ececec;
}

.mem-char-info-card .mcic-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #e5e5ea;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

.mem-char-info-card .mcic-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mem-char-info-card .mcic-avatar svg {
  width: 24px;
  height: 24px;
  stroke: #8e8e93;
  fill: none;
  stroke-width: 1.5;
}

.mem-char-info-card .mcic-info {
  flex: 1;
}

.mem-char-info-card .mcic-name {
  font-size: 17px;
  font-weight: 600;
  color: #1d1d1f;
}

.mem-char-info-card .mcic-stats {
  font-size: 12px;
  color: #8e8e93;
  margin-top: 3px;
}

/* ===== Memory Edit: 类型选择行居中 ===== */
.mem-type-row {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
}

/* ===== iOS 风格分段横条（Segmented Control）===== */
.mem-seg-control {
  display: flex;
  background: #e5e5ea;
  border-radius: 8px;
  padding: 2px;
  width: 100%;
  max-width: 260px;
  position: relative;
}

.mem-seg-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #8e8e93;
  cursor: pointer;
  transition: all .2s ease;
  background: transparent;
  border: none;
  outline: none;
  position: relative;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.mem-seg-option.active {
  background: #fff;
  color: #1d1d1f;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
}

.mem-seg-option:active {
  opacity: .7;
}

.mem-seg-option svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  flex-shrink: 0;
}

/* ===== 记忆检索设置面板 ===== */
.retrieval-settings-card {
  margin: 0 16px 16px;
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid #ececec;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.rs-section-title {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 16px;
}

.rs-sub-title {
  font-size: 13px;
  font-weight: 600;
  color: #3a3a3c;
  margin: 12px 0 8px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.rs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.rs-btn-row {
  margin-top: 4px;
  gap: 10px;
}

.rs-label {
  font-size: 13px;
  color: #3a3a3c;
  flex-shrink: 0;
  min-width: 90px;
}

.rs-input, .rs-select {
  flex: 1;
  background: #f2f2f7;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: #1d1d1f;
  outline: none;
  min-width: 0;
}

.rs-input:focus, .rs-select:focus {
  background: #e8e8ed;
}

.rs-divider {
  height: 1px;
  background: #f2f2f7;
  margin: 8px 0;
}

.rs-btn {
  padding: 9px 18px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  background: #f2f2f7;
  color: #3a3a3c;
  cursor: pointer;
  transition: opacity .15s;
}

.rs-btn:active { opacity: .7; }

.rs-btn-primary {
  background: #1d1d1f;
  color: #fff;
  flex: 1;
}

.rs-test-result {
  font-size: 13px;
  font-weight: 500;
}

/* Toggle switch */
.rs-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

.rs-toggle input { opacity: 0; width: 0; height: 0; }

.rs-toggle-track {
  position: absolute;
  inset: 0;
  background: #e5e5ea;
  border-radius: 13px;
  transition: background .2s;
  cursor: pointer;
}

.rs-toggle-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}

.rs-toggle input:checked + .rs-toggle-track { background: #34c759; }
.rs-toggle input:checked + .rs-toggle-track::after { transform: translateX(18px); }

/* ===== 核心记忆标签 & 按钮 ===== */
.mem-type-core {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: #fff8e7;
  color: #b8860b;
  border: 1px solid #f5d87a;
  line-height: 1.5;
  white-space: nowrap;
  gap: 2px;
}

.mem-type-ftm {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: #f0f0ff;
  color: #7070cc;
  border: 1px solid #d0d0f0;
  line-height: 1.5;
  white-space: nowrap;
}

/* 升级/取消核心记忆按钮 */
.mem-core-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f5f5f7;
  color: #c7c7cc;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .2s;
  margin-left: auto;
}

.mem-core-btn:active {
  opacity: .6;
  transform: scale(.9);
}

.mem-core-btn--active {
  background: #fff8e7;
  color: #d4a017;
}

.mem-core-btn--active:active {
  opacity: .7;
}

/* 核心记忆卡片高亮边框 */
.mem-tl-item:has(.mem-type-core) .mem-tl-card {
  border-color: #f5d87a;
  box-shadow: 0 1px 6px rgba(212, 160, 23, .12);
}
