*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #161618;
  --surface2: #1a1a1e;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --text-dim: #888;
  --accent: #7c6fcd;
  --accent-dim: #3d3660;
  --user-bg: rgba(61, 47, 110, 0.92);
  --assistant-bg: rgba(26, 26, 30, 0.92);
  --radius: 12px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }

.layout {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  grid-template-rows: 1fr auto;
  height: 100vh;
  overflow: hidden;
}

/* ── sidebar ── */
.sidebar {
  grid-column: 1;
  grid-row: 1;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── sidebar brand ── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-brand-logo {
  width: 32px; height: 32px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-title { font-weight: 700; font-size: 13px; color: var(--text); line-height: 1.2; }
.sidebar-brand-sub { font-size: 11px; color: var(--text-dim); margin-top: 1px; }

/* ── session list header ── */
.session-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.session-new-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--accent-dim); color: var(--accent);
  border: none; border-radius: 6px;
  cursor: pointer; font-size: 12px; font-weight: 500;
  transition: background .15s;
}
.session-new-btn:hover { background: var(--accent); color: #fff; }

/* ── sidebar shortcuts ── */
.sidebar-shortcuts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.shortcut-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 8px;
  background: none; border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 7px;
  font-size: 11px; cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap; overflow: hidden;
}
.shortcut-btn:hover { background: var(--border); color: var(--text); }

/* ── sidebar mood bar ── */
.sidebar-mood-bar {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── sidebar header (legacy, kept for compat) ── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-title { font-weight: 600; color: var(--text-dim); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
.sidebar-header button {
  width: 26px; height: 26px;
  background: var(--accent-dim); color: var(--accent);
  border: none; border-radius: 6px;
  cursor: pointer; font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.sidebar-header button:hover { background: var(--accent); color: #fff; }

#session-list { list-style: none; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; padding: 6px 0; }

/* ── sidebar overlay (mobile) ── */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 90;
}
.sidebar-overlay.hidden { display: none; }

/* ── chat area ── */
.chat-area {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

/* ── chat header bar ── */
.chat-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.chat-header-left { display: flex; align-items: center; gap: 10px; }
.chat-header-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; flex-shrink: 0;
  overflow: hidden; cursor: pointer;
}
.chat-header-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.chat-title { font-weight: 600; color: var(--text); font-size: 15px; }
.chat-header-actions { display: flex; gap: 6px; }
.chat-action-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 10px;
  background: none; border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 6px;
  font-size: 12px; cursor: pointer;
  transition: background .15s, color .15s, opacity .15s;
}
.chat-action-btn:hover { background: var(--border); color: var(--text); }
.chat-action-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chat-action-btn.active:hover { opacity: .85; }
.chat-action-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ── 沉浸模式状态指示 ── */
.immersive-status {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  margin-left: 4px;
}
.immersive-mood {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.immersive-mood-label { color: var(--text-dim); }
.immersive-heart { color: #ff6b9d; font-size: 13px; }
#immersive-heart-count { color: #ff6b9d; font-weight: 600; }

/* ── 沉浸模式布局 ── */
.layout.immersive {
  grid-template-columns: 0 1fr 0;
}
.layout.immersive .sidebar,
.layout.immersive .right-panel,
.layout.immersive .bottom-nav,
.layout.immersive .input-hint {
  display: none;
}
.layout.immersive .immersive-status {
  display: flex;
}
.layout.immersive .chat-area {
  border-right: none;
  grid-row: 1 / -1;
}

#messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 0;
  scroll-behavior: smooth;
  position: relative;
  background-image:
    linear-gradient(rgba(15,15,15,var(--chat-bg-dim,1)), rgba(15,15,15,var(--chat-bg-dim,1))),
    var(--chat-bg-url, none);
  background-size: cover;
  background-position: center;
}

.bubble-wrap {
  display: flex;
  padding: 6px 24px;
  gap: 10px;
  align-items: flex-end;
}
.bubble-wrap.user { flex-direction: row-reverse; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
  overflow: hidden; cursor: pointer;
  transition: opacity .15s;
}
.avatar:hover { opacity: .75; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.bubble-wrap.user .avatar { background: #1e2a3a; color: #6aa4d4; }

.avatar-lg {
  width: 72px; height: 72px;
  font-size: 28px;
  margin: 0 auto;
  cursor: default;
}
.avatar-lg:hover { opacity: 1; }

.avatar-preview-row { display: flex; justify-content: center; margin-bottom: 16px; }

.avatar-actions {
  display: flex; gap: 8px; justify-content: center; margin-bottom: 16px;
}

.btn-upload {
  padding: 7px 16px;
  background: var(--accent-dim); color: var(--accent);
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background .15s;
}
.btn-upload:hover { background: var(--accent); color: #fff; }

#avatar-remove {
  padding: 7px 16px;
  background: var(--border); color: var(--text-dim);
  border: none; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: background .15s;
}
#avatar-remove:hover { background: #333; color: var(--text); }

#avatar-save { background: var(--accent); color: #fff; }
#avatar-save:hover { background: #9080e0; }
#avatar-cancel { background: var(--border); color: var(--text-dim); }
#avatar-cancel:hover { background: #333; color: var(--text); }

.avatar-modal-box { min-width: 320px; max-width: 400px; }

/* ── 裁剪 ── */
.crop-wrap {
  position: relative;
  width: 280px; height: 280px;
  margin: 0 auto 8px;
  border-radius: 50%;
  overflow: hidden;
  background: #111;
  cursor: grab;
}
.crop-wrap:active { cursor: grabbing; }

#crop-canvas {
  position: absolute;
  top: 0; left: 0;
  touch-action: none;
  user-select: none;
}

/* 圆形遮罩：在 canvas 上叠一个圆形边框提示 */
.crop-circle-mask {
  position: absolute; inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.55);
  pointer-events: none;
}

.crop-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 16px;
}

#crop-confirm { background: var(--accent); color: #fff; }
#crop-confirm:hover { background: #9080e0; }
#crop-cancel { background: var(--border); color: var(--text-dim); }
#crop-cancel:hover { background: #333; color: var(--text); }

/* ── 右键菜单 ── */
.ctx-menu {
  position: fixed;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  min-width: 130px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.ctx-menu.hidden { display: none; }
.ctx-menu button {
  display: block; width: 100%;
  padding: 9px 16px;
  background: none; border: none;
  color: var(--text); font-size: 13px;
  text-align: left; cursor: pointer;
  transition: background .1s;
}
.ctx-menu button:hover { background: rgba(255,255,255,.06); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 28px; left: 50%; transform: translateX(-50%);
  background: rgba(40,40,40,.95);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 20px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 300;
  pointer-events: none;
  transition: opacity .2s;
}
.toast.hidden { opacity: 0; }

.bubble {
  max-width: 62%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble-wrap.assistant .bubble { background: var(--assistant-bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble-wrap.user .bubble { background: var(--user-bg); border-bottom-right-radius: 4px; }

.bubble .action-text { color: #a89fd8; font-size: 0.9em; font-style: italic; }

.bubble .action-line {
  color: #a89fd8;
  font-size: 0.88em;
  font-style: italic;
  padding-left: 8px;
  border-left: 2px solid #5a5090;
  margin: 4px 0;
  line-height: 1.5;
}
.bubble .action-line.action-hidden { display: none; }
.bubble .action-details { margin: 4px 0; }
.bubble .action-details summary.action-line {
  list-style: none;
  cursor: pointer;
  display: block;
}
.bubble .action-details summary.action-line::before {
  content: "▸ ";
  font-style: normal;
  font-size: 0.8em;
  opacity: 0.7;
}
.bubble .action-details[open] summary.action-line::before { content: "▾ "; }
.bubble .speech-line {
  margin: 4px 0;
  line-height: 1.6;
}
.bubble .action-line:first-child,
.bubble .speech-line:first-child { margin-top: 0; }
.bubble .action-line:last-child,
.bubble .speech-line:last-child { margin-bottom: 0; }

.bubble.thinking { color: var(--text-dim); font-style: italic; }

/* ── 重新生成按钮 ── */
.btn-regen {
  opacity: 0;
  pointer-events: none;
  align-self: flex-end;
  margin-bottom: 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 3px;
  border-radius: 4px;
  line-height: 1;
  transition: opacity .15s, color .15s;
}
.bubble-wrap:hover .btn-regen { opacity: 1; pointer-events: auto; }
.btn-regen:hover { color: var(--accent); }

.btn-del-msg {
  opacity: 0;
  pointer-events: none;
  align-self: flex-start;
  margin-top: 4px;
  order: 99;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 3px;
  border-radius: 4px;
  line-height: 1;
  transition: opacity .15s, color .15s;
}
.bubble-wrap:hover .btn-del-msg { opacity: 1; pointer-events: auto; }
.btn-del-msg:hover { color: #e05; }
.bubble-wrap.user .btn-del-msg { order: -1; }

/* ── 消息内图片 ── */
.bubble .bubble-img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 8px;
  cursor: pointer;
  display: block;
  transition: opacity .2s;
}
.bubble .bubble-img:hover { opacity: .85; }

.bubble .img-toggle-btn {
  margin-top: 8px;
  padding: 4px 12px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
}
.bubble .img-toggle-btn:hover:not(:disabled) { background: rgba(255,255,255,0.18); }
.bubble .img-toggle-btn:disabled { opacity: .5; cursor: default; }

.img-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 12px;
}
.img-loading .spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 图片灯箱 ── */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 400;
  cursor: zoom-out;
}
.lightbox.hidden { display: none; }
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
}

.empty-hint {
  text-align: center;
  color: var(--text-dim);
  padding-top: 30vh;
  font-size: 13px;
}

/* ── input area ── */
.input-area {
  flex-shrink: 0;
  padding: 12px 16px 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.input-row {
  display: flex;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  align-items: flex-end;
  transition: border-color .15s;
}
.input-row:focus-within { border-color: var(--accent); }

.input-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 6px;
}

.btn-img {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 50%;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.btn-img:hover { background: var(--border); color: var(--text); }

.btn-scene-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 50%;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.btn-scene-image:hover { background: var(--border); color: var(--accent); }
.btn-scene-image:disabled { opacity: 0.4; cursor: not-allowed; }

#input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px 0;
  font-size: 14px;
  resize: none;
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
  font-family: inherit;
}
#input:focus { outline: none; }

#btn-send {
  width: 36px; height: 36px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
  align-self: flex-end;
  margin-bottom: 1px;
}
#btn-send:hover { background: #9080e0; }
#btn-send:disabled { background: var(--accent-dim); cursor: not-allowed; }

/* scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

/* ── modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  min-width: 280px;
  max-width: 360px;
  text-align: center;
}

.modal p { margin-bottom: 20px; line-height: 1.6; color: var(--text); }

.modal-actions { display: flex; gap: 10px; justify-content: center; }

.modal-actions button {
  padding: 8px 20px;
  border: none; border-radius: 8px;
  cursor: pointer; font-size: 14px; font-weight: 500;
  transition: background .15s;
}

#modal-yes { background: var(--accent); color: #fff; }
#modal-yes:hover { background: #9080e0; }
#modal-no { background: var(--border); color: var(--text-dim); }
#modal-no:hover { background: #333; color: var(--text); }

/* ── 汉堡按钮（桌面隐藏，移动端显示）── */
.btn-hamburger {
  display: none;
  background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  padding: 4px 6px; border-radius: 6px;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color .15s, background .15s;
  margin-right: 6px;
}
.btn-hamburger:hover { color: var(--text); background: var(--border); }

/* ── H5 / 移动端 ── */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  /* 侧边栏：固定抽屉，从左滑入 */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }

  /* 右侧面板：固定抽屉，从右滑入 */
  .right-panel {
    display: flex !important;
    position: fixed; top: 0; right: 0; bottom: 0;
    z-index: 101;
    transform: translateX(100%);
    transition: transform .25s ease;
    width: 300px;
    background: var(--surface);
    overflow-y: auto;
  }
  .right-panel.open { transform: translateX(0); }

  .chat-area { grid-column: 1; border-right: none; }
  .bottom-nav {
    grid-column: 1;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* 汉堡按钮显示 */
  .btn-hamburger { display: flex; }

  /* 消息气泡 */
  .bubble { max-width: 82%; font-size: 15px; padding: 12px 16px; line-height: 1.7; }
  .bubble-wrap { padding: 6px 12px; gap: 8px; }
  #messages { padding: 16px 0; }

  /* 输入区 */
  .input-row { padding: 6px 8px 6px 12px; }
  #input { font-size: 16px; } /* 防止 iOS 自动缩放 */
  #btn-send { width: 38px; height: 38px; }
  .btn-img { width: 32px; height: 32px; }
  .avatar { width: 30px; height: 30px; font-size: 12px; }
  .input-area { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }

  /* 弹窗全屏化 */
  .modal { min-width: auto; max-width: 92vw; padding: 20px 22px; }
  .gallery-box {
    width: 100vw; max-width: 100vw;
    max-height: 100dvh; height: 100dvh;
    border-radius: 0;
  }
  .settings-modal-box {
    width: 92vw; max-width: 92vw;
    min-width: auto;
    max-height: 90dvh;
    overflow-y: auto;
  }
  .avatar-modal-box { min-width: auto; width: 92vw; max-width: 92vw; }

  /* 搜索结果：固定在底部导航上方 */
  .search-results {
    left: 0; right: 0; width: auto;
    top: auto;
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    max-height: 55vh;
    border-radius: 8px 8px 0 0;
  }

  /* 会话列表 */
  #session-list li { padding: 12px 16px; font-size: 14px; }

  /* 灯箱 */
  .lightbox img { max-width: 96vw; max-height: 96vh; }
}

/* ── 情绪指示 ── */
.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.chat-toolbar.hidden { display: none; }

.mood-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px 4px 8px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--mood-color, #555) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--mood-color, #555) 35%, transparent);
  font-size: 13px;
  font-weight: 500;
  color: var(--mood-color, #888);
  cursor: default;
  transition: background .3s, border-color .3s, color .3s;
}
.mood-indicator .mood-emoji {
  font-size: 20px;
  line-height: 1;
}
.mood-indicator .mood-avatar-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.mood-indicator.hidden { display: none; }

.toolbar-right { display: flex; gap: 6px; }
.toolbar-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: none; border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 6px;
  font-size: 12px; cursor: pointer;
  transition: background .15s, color .15s;
}
.toolbar-btn:hover { background: var(--border); color: var(--text); }

/* ── 时间戳 ── */
.bubble-wrap .ts {
  font-size: 11px;
  color: var(--text-dim);
  align-self: flex-end;
  margin-bottom: 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s;
}
.bubble-wrap:hover .ts { opacity: 1; }
/* user 消息是 row-reverse，ts 在 DOM 末尾会跑到最左；用 order:-1 让它回到最右 */
.bubble-wrap.user .ts { order: -2; }

/* ── 打字动画 ── */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 2px;
}
.typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: dot-bounce .9s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ── 长对话折叠 ── */
.load-more {
  text-align: center;
  padding: 12px 0 4px;
}
.load-more button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 20px;
  padding: 5px 18px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.load-more button:hover { background: var(--border); color: var(--text); }

/* ── 搜索 ── */
.sidebar-actions { display: flex; gap: 4px; align-items: center; }
.sidebar-actions button {
  width: 26px; height: 26px;
  background: var(--accent-dim); color: var(--accent);
  border: none; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.sidebar-actions button:hover { background: var(--accent); color: #fff; }

.search-bar {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-bar input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
}
.search-bar input:focus { outline: none; border-color: var(--accent); }

.search-results {
  position: absolute;
  top: 0; left: 220px;
  width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 150;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  padding: 6px 0;
}
.search-results.hidden { display: none; }
.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(255,255,255,.04); }
.search-result-item .sr-session { font-size: 11px; color: var(--accent); margin-bottom: 3px; }
.search-result-item .sr-content { font-size: 13px; color: var(--text); line-height: 1.4; }
.search-result-item .sr-content em { color: var(--accent); font-style: normal; }

/* ── 图片画廊 ── */
.gallery-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(90vw, 860px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.gallery-header button {
  background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  font-size: 16px; padding: 2px 6px;
  border-radius: 4px;
  transition: background .15s;
}
.gallery-header button:hover { background: var(--border); color: var(--text); }

/* 瀑布流容器 */
.gallery-grid {
  columns: 3 160px;
  column-gap: 8px;
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}
.gallery-item {
  break-inside: avoid;
  margin-bottom: 8px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
  position: relative;
  display: block;
}
.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity .2s;
}
.gallery-item:hover img { opacity: .8; }
.gallery-item .gi-session {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  color: #fff; font-size: 10px;
  padding: 12px 6px 4px;
  opacity: 0; transition: opacity .2s;
}
.gallery-item:hover .gi-session { opacity: 1; }

.gallery-loader {
  display: flex;
  justify-content: center;
  padding: 16px 0;
  column-span: all;
  break-inside: avoid;
}
.gallery-empty {
  color: var(--text-dim);
  font-size: 13px;
  padding: 40px 20px;
  text-align: center;
  column-span: all;
}

/* ── 设置面板 ── */
.settings-modal-box { min-width: 300px; max-width: 480px; max-height: 85vh; overflow-y: auto; text-align: left; }
.settings-modal-box > p { margin-bottom: 16px; font-weight: 600; text-align: center; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.settings-row label { font-size: 13px; color: var(--text-dim); }
.time-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  width: 120px;
}
.time-input:focus { outline: none; border-color: var(--accent); }
.settings-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.5;
  text-align: left !important;
}
#settings-save { background: var(--accent); color: #fff; }
#settings-save:hover { background: #9080e0; }
#settings-cancel { background: var(--border); color: var(--text-dim); }
#settings-cancel:hover { background: #333; color: var(--text); }

/* ── 头像情绪 tab ── */
.mood-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 14px;
}
.mood-tab {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.mood-tab:hover { background: var(--border); color: var(--text); }
.mood-tab.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.mood-tab.has-avatar::after { content: "·"; margin-left: 3px; color: var(--accent); font-weight: bold; }

/* ── 生图失败提示 ── */
.img-error {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: #e05;
  font-size: 12px;
}

.img-retry-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 12px;
  background: none;
  border: 1px solid #e05;
  border-radius: 12px;
  color: #e05;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.img-retry-btn:hover { background: #e05; color: #fff; }
.img-retry-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── 右侧角色面板 ── */
.right-panel {
  grid-column: 3;
  grid-row: 1;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.rp-header {
  padding: 12px 16px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rp-close-btn {
  display: none;
  background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  padding: 3px; border-radius: 4px;
  align-items: center; justify-content: center;
  transition: color .15s;
}
.rp-close-btn:hover { color: var(--text); }
@media (max-width: 768px) {
  .rp-close-btn { display: flex; }
}

/* ── 角色卡片 ── */
.rp-avatar-section {
  position: relative;
  width: 100%;
  aspect-ratio: 2/3;
  max-height: 340px;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(160deg, #1a1230 0%, #0f0f1a 100%);
}
.rp-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  transition: opacity .3s;
}
.rp-card-img.hidden { opacity: 0; }

/* 卡片底部渐变遮罩 + 名字/心动 */
.rp-card-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 40px 14px 14px;
  background: linear-gradient(transparent, rgba(10,8,20,.85) 60%);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}
.rp-card-name {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.rp-heart-btn {
  display: flex; align-items: center; gap: 4px;
  position: relative;
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.2);
  cursor: pointer;
  color: #ff6b9d;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 14px;
  transition: background .15s;
}
.rp-heart-btn:hover { background: rgba(255,107,157,.2); }

.affection-delta {
  position: absolute;
  font-size: 18px;
  font-weight: 800;
  pointer-events: none;
  animation: affection-float 2s ease-out forwards;
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
  white-space: nowrap;
}
.affection-delta.up { color: #ff6b9d; }
.affection-delta.down { color: #aaa; }
@keyframes affection-float {
  0%   { opacity: 1; transform: translateY(0) scale(1.2); }
  20%  { opacity: 1; transform: translateY(-8px) scale(1.3); }
  100% { opacity: 0; transform: translateY(-36px) scale(1); }
}

/* 卡片骨架屏（生成中） */
.rp-card-skeleton {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, #1a1230 0%, #0f0f1a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 12px;
}
.rp-card-skeleton .spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.rp-card-skeleton.hidden { display: none; }

/* 卡片操作按钮（右上角） */
.rp-card-actions {
  position: absolute;
  top: 8px; right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .2s;
}
.rp-avatar-section:hover .rp-card-actions { opacity: 1; }
.rp-card-btn {
  width: 28px; height: 28px;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.rp-card-btn:hover { background: rgba(124,111,205,.7); }
.rp-card-btn:disabled { opacity: .4; cursor: not-allowed; }

/* 旧的 char-name-row 不再需要 */
.rp-char-name-row { display: none; }

/* ── 卡片库 ── */
.card-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  padding: 14px;
  overflow-y: auto;
}
.card-library-item {
  position: relative;
  aspect-ratio: 2/3;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
  border: 2px solid transparent;
  transition: border-color .15s;
}
.card-library-item.active { border-color: var(--accent); }
.card-library-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: opacity .2s;
}
.card-library-item:hover img { opacity: .85; }
.card-library-item .cli-badge {
  position: absolute; top: 6px; left: 6px;
  background: var(--accent);
  color: #fff; font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
}
.card-library-item .cli-del {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,.6);
  border: none; border-radius: 4px;
  color: #fff; font-size: 13px;
  cursor: pointer; display: none;
  align-items: center; justify-content: center;
  transition: background .15s;
}
.card-library-item:hover .cli-del { display: flex; }
.card-library-item .cli-del:hover { background: #e05; }

/* ── 设置分隔线 ── */
.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0 12px;
}

.soul-field-input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
  line-height: 1.5;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.soul-field-input:focus { outline: none; border-color: var(--accent); }

.rp-soul-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}
.rp-soul-header:hover .rp-section-title { color: var(--text); }
.rp-soul-chevron { transition: transform .2s; color: var(--text-dim); flex-shrink: 0; }
.rp-soul-header.open .rp-soul-chevron { transform: rotate(180deg); }
.rp-soul-body { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.rp-soul-body.hidden { display: none; }
.rp-soul-field { display: flex; flex-direction: column; gap: 4px; }
.rp-soul-field label { font-size: 11px; color: var(--text-dim); }

.rp-section {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.rp-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.rp-info-text {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.rp-mood-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
}
.rp-mood-label-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.rp-mood-label-emoji {
  font-size: 52px;
  line-height: 1;
}
.rp-mood-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.rp-mood-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  opacity: .35;
  transition: opacity .2s, transform .2s;
  cursor: default;
}
.rp-mood-dot.active { opacity: 1; transform: scale(1.3); }

.rp-ingest-btn {
  margin-top: 8px;
  width: 100%;
  padding: 7px 0;
  background: var(--accent-dim); color: var(--accent);
  border: none; border-radius: 7px;
  font-size: 12px; cursor: pointer;
  transition: background .15s;
}
.rp-ingest-btn:hover { background: var(--accent); color: #fff; }

.rp-dnd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rp-toggle {
  width: 36px; height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.rp-toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform .2s, background .2s;
}
.rp-toggle.on { background: var(--accent-dim); }
.rp-toggle.on::after { transform: translateX(16px); background: var(--accent); }

.rp-recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.rp-view-all {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 11px;
  padding: 2px 0;
  transition: opacity .15s;
}
.rp-view-all:hover { opacity: .7; }
.rp-recent-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rp-recent-img {
  width: 100%;
  border-radius: 7px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
  aspect-ratio: 16/9;
}
.rp-recent-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity .2s;
}
.rp-recent-img:hover img { opacity: .8; }

/* ── 底部导航 ── */
.bottom-nav {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0;
}
.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  background: none; border: none;
  color: var(--text-dim);
  font-size: 10px;
  cursor: pointer;
  transition: color .15s, background .15s;
  border-top: 2px solid transparent;
}
.nav-tab:hover { color: var(--text); background: rgba(255,255,255,.03); }
.nav-tab.active { color: var(--accent); border-top-color: var(--accent); }

/* ── session list item with meta ── */
#session-list li {
  padding: 9px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background .1s, color .1s;
  position: relative;
}
#session-list li:hover { background: rgba(255,255,255,.04); }
#session-list li.active { border-left-color: var(--accent); background: rgba(124,111,205,.1); }

.sl-title {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.sl-preview {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#session-list li .del-btn {
  display: none;
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: #555; font-size: 15px; line-height: 1;
  padding: 2px 4px;
}
#session-list li:hover .del-btn { display: block; }
#session-list li .del-btn:hover { color: #e05; }

/* ── 归档会话列表 ── */
.archived-list {
  padding: 8px 0;
  max-height: 60vh;
  overflow-y: auto;
}
.archived-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.archived-item:last-child { border-bottom: none; }
.archived-info {
  flex: 1;
  min-width: 0;
}
.archived-title {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}
.archived-preview {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.archived-restore-btn {
  flex-shrink: 0;
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.archived-restore-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ── 半自动回复选项 ── */
.reply-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 14px;
}
.suggestion-btn {
  padding: 7px 14px;
  border-radius: 18px;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-align: left;
  line-height: 1.4;
}
.suggestion-btn:hover {
  background: var(--accent);
  color: #fff;
}

.companion-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(92vw, 400px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.companion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.companion-header span {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.companion-header button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.companion-header button:hover {
  background: var(--surface2);
  color: var(--text);
}
.companion-body {
  overflow-y: auto;
  flex: 1;
  padding: 0 0 16px;
}

/* ── affection log ── */
.affection-log-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.affection-log-item:last-child { border-bottom: none; }
.affection-log-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}
.affection-log-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.affection-log-delta {
  font-size: 15px;
  font-weight: 700;
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
  padding-top: 2px;
}
.affection-log-delta.up   { color: #ff6b9d; }
.affection-log-delta.down { color: #888; }
.affection-log-delta.zero { color: var(--text-dim); }
.affection-log-content { flex: 1; min-width: 0; }
.affection-log-reason {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-all;
}
.affection-log-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* ── auth page ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.auth-container {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.auth-logo-icon {
  width: 36px; height: 36px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.auth-logo-title { font-weight: 700; font-size: 16px; }
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 7px 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; display: block; }
.auth-form input {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.auth-form input:focus { border-color: var(--accent); }
.auth-submit {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s;
}
.auth-submit:hover { opacity: 0.85; }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-error {
  color: #ff6b6b;
  font-size: 12px;
  text-align: center;
  min-height: 18px;
}

/* ── 成就弹窗 ─────────────────────────────────────────────────────────────── */
.achievement-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: ach-overlay-in 0.25s ease both;
}
@keyframes ach-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.achievement-box {
  background: var(--bg-panel, #1e1a2e);
  border: 1px solid var(--border, #3a3560);
  border-radius: 20px;
  padding: 32px 28px 24px;
  width: 300px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transform: scale(0.8);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}
.achievement-box-in {
  transform: scale(1);
  opacity: 1;
}
.achievement-header {
  font-size: 13px;
  color: var(--text-dim, #888);
  letter-spacing: 2px;
  text-transform: uppercase;
  animation: ach-fadeslide 0.4s 0.15s ease both;
}
.achievement-selfie-wrap {
  width: 200px;
  height: 200px;
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid #c9a84c;
  box-shadow: 0 0 18px rgba(201, 168, 76, 0.5);
  flex-shrink: 0;
  animation: ach-selfie-pop 0.5s 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) both,
             ach-glow-pulse 2.5s 0.7s ease-in-out infinite;
}
@keyframes ach-selfie-pop {
  from { transform: scale(0.5) rotate(-8deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);   opacity: 1; }
}
@keyframes ach-glow-pulse {
  0%, 100% { box-shadow: 0 0 18px var(--ach-glow, rgba(201, 168, 76, 0.45)); }
  50%       { box-shadow: 0 0 32px var(--ach-glow, rgba(201, 168, 76, 0.85)), 0 0 60px var(--ach-glow, rgba(201, 168, 76, 0.25)); }
}
.achievement-selfie {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.achievement-selfie-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  background: var(--bg-input, #2a2545);
}
.achievement-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent, #a78bfa);
  text-align: center;
  animation: ach-fadeslide 0.4s 0.35s ease both;
}
.achievement-voice {
  font-size: 13px;
  font-style: italic;
  color: var(--text-dim, #888);
  text-align: center;
  line-height: 1.6;
  max-width: 240px;
  animation: ach-fadeslide 0.4s 0.5s ease both;
}
.achievement-btn {
  margin-top: 4px;
  padding: 10px 32px;
  background: var(--accent, #a78bfa);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  animation: ach-fadeslide 0.4s 0.65s ease both;
}
.achievement-btn:hover { opacity: 0.85; transform: scale(1.04); }
@keyframes ach-fadeslide {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 成就回顾列表 ─────────────────────────────────────────────────────────── */
.ach-review-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  cursor: pointer;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  animation: ach-card-in 0.4s ease both;
}
@keyframes ach-card-in {
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.ach-review-selfie-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--ach-color, #c9a84c);
  box-shadow: 0 0 14px var(--ach-glow, rgba(201, 168, 76, 0.3));
  flex-shrink: 0;
  position: relative;
  transition: transform 0.18s, box-shadow 0.18s;
}
.ach-review-item:hover .ach-review-selfie-wrap {
  transform: scale(1.03);
  box-shadow: 0 0 28px var(--ach-glow, rgba(201, 168, 76, 0.6));
}
.ach-review-type-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-size: 16px;
  line-height: 1;
  background: rgba(0,0,0,0.45);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ach-review-selfie { width: 100%; height: 100%; object-fit: cover; display: block; }
.ach-review-selfie-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  background: var(--bg-input, #2a2545);
}
.ach-review-info {
  width: 100%;
  padding: 8px 4px 0;
  text-align: center;
}
.ach-review-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ach-review-voice {
  font-size: 12px;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.4;
  margin-bottom: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ach-review-date {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.6;
}

/* 成就网格容器 */
#achievements-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 16px !important;
}

/* 成就大图灯箱 */
.ach-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 24px;
  gap: 16px;
  cursor: zoom-out;
  animation: ach-lb-bg-in 0.25s ease both;
}
@keyframes ach-lb-bg-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.ach-lightbox-img {
  max-width: min(90vw, 480px);
  max-height: 70vh;
  border-radius: 16px;
  border: 3px solid #c9a84c;
  box-shadow: 0 0 40px rgba(201, 168, 76, 0.4);
  object-fit: contain;
  display: block;
  animation: ach-lb-img-in 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) both,
             ach-glow-pulse 3s 0.35s ease-in-out infinite;
}
@keyframes ach-lb-img-in {
  from { transform: scale(0.82); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.ach-lightbox-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent, #a78bfa);
  animation: ach-fadeslide 0.35s 0.15s ease both;
}
.ach-lightbox-voice {
  font-size: 14px;
  font-style: italic;
  color: rgba(255,255,255,0.7);
  text-align: center;
  max-width: 360px;
  line-height: 1.6;
  animation: ach-fadeslide 0.35s 0.25s ease both;
}
.ach-lightbox-date {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  animation: ach-fadeslide 0.35s 0.35s ease both;
}
.ach-lightbox-badge {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  border: 1px solid;
  border-radius: 20px;
  padding: 3px 12px;
  opacity: 0.85;
  animation: ach-fadeslide 0.35s 0.1s ease both;
}
