/* =========================================
   style.css — 与星同行·对话页面
   三栏布局：记忆抽屉 + 正文区 + 状态面板
   ========================================= */

/* ========== CSS变量 ========== */
:root {
  --bg-deep: #1a1030;
  --bg-mid: #2d1a4a;
  --bg-glow: #4a2d7a;
  --dream-purple: #9060d0;
  --dream-light: #c898f0;
  --dream-glow: rgba(180, 120, 220, 0.4);
  --dream-pink: #f0a8e8;
  --dream-blue: #a8c8f0;

  --panel-bg: #f8f4ff;
  --panel-bg-warm: #f5edff;
  --panel-text: #3a2858;
  --panel-text-light: #6a5a8a;
  --panel-border: #d8c8e8;
  --panel-line: #e8ddf0;
  --panel-shadow: rgba(40, 20, 80, 0.15);

  --pink-warm: #f48fb1;
  --pink-deep: #e91e63;
  --pink-soft: #fce4ec;

  --hot-red: #ff4444;
  --hot-red-light: #ff6666;

  --drawer-width: 300px;
  --left-panel-width: 300px;
  --right-panel-width: 360px;
  --top-bar-height: 48px;

  --base-font-size: 15px;
  --fs-body: 15px;
  --fs-panel: 12px;
  --fs-title: 22px;
  --fs-meta: 11px;

  /* ========== 社媒配色变量 ========== */
  --social-panel-bg: #121214;
  --social-body-bg: #0e0e10;
  --social-header-bg: linear-gradient(135deg, #1a1a20, #252530);
  --social-header-text: #e0e0e0;
  --social-reply-section-bg: rgba(255,255,255,0.03);
  --social-player-bg: rgba(144, 96, 208, 0.15);
  --social-player-border: #9060d0;
  --social-player-text: #e8d8f8;
  --social-player-author: #c8a8e8;
  --social-npc-text: #aaa;
  --social-npc-author: #8af;
  --social-input-bg: rgba(255,255,255,0.05);
  --social-input-text: #fff;
  --social-input-border: rgba(255,255,255,0.1);
  --social-input-placeholder: #555;
  --social-btn-bg: #5b8ff9;
  --social-btn-text: #fff;
}

/* ========== 主题：午夜蓝 ========== */
body[data-theme="midnight"] {
  --bg-deep: #0a1228;
  --bg-mid: #122040;
  --bg-glow: #1a3055;
  --dream-purple: #4080d0;
  --dream-light: #80b0f0;
  --dream-glow: rgba(80, 140, 220, 0.4);
  --dream-pink: #80c0f0;
  --dream-blue: #c0d8f0;
  --panel-bg: #f0f4ff;
  --panel-bg-warm: #e8efff;
  --panel-text: #1a2848;
  --panel-text-light: #4a5a7a;
  --panel-border: #c0d0e8;
  --panel-line: #d8e0f0;
  --pink-warm: #6aa0d0;
  --pink-deep: #2070b0;
}

/* ========== 主题：玫瑰红 ========== */
body[data-theme="rose"] {
  --bg-deep: #2a0a20;
  --bg-mid: #401530;
  --bg-glow: #5a2045;
  --dream-purple: #d04080;
  --dream-light: #f080b0;
  --dream-glow: rgba(220, 100, 160, 0.4);
  --dream-pink: #f0a0c0;
  --dream-blue: #c0a0d8;
  --panel-bg: #fff4f8;
  --panel-bg-warm: #ffe8f0;
  --panel-text: #4a1a38;
  --panel-text-light: #7a4a68;
  --panel-border: #e8c0d8;
  --panel-line: #f0d8e8;
  --pink-warm: #e06090;
  --pink-deep: #c01060;
}

/* ========== 主题：暗夜森林 ========== */
body[data-theme="forest"] {
  --bg-deep: #0a2010;
  --bg-mid: #103020;
  --bg-glow: #1a4530;
  --dream-purple: #40a060;
  --dream-light: #80d0a0;
  --dream-glow: rgba(80, 180, 120, 0.4);
  --dream-pink: #a0e0c0;
  --dream-blue: #80c0a0;
  --panel-bg: #f0fff4;
  --panel-bg-warm: #e8ffe8;
  --panel-text: #1a3a28;
  --panel-text-light: #4a6a5a;
  --panel-border: #c0e0c8;
  --panel-line: #d8f0d8;
  --pink-warm: #60b080;
  --pink-deep: #208050;
}

/* ========== 主题：暖砂（护眼暖色） ========== */
body[data-theme="warm-sand"] {
  --bg-deep: #1e1810;
  --bg-mid: #2a2018;
  --bg-glow: #3a2e22;
  --dream-purple: #c0986a;
  --dream-light: #e0c898;
  --dream-glow: rgba(192, 152, 106, 0.3);
  --dream-pink: #d8b890;
  --dream-blue: #b8c8a0;
  --panel-bg: #faf6ef;
  --panel-bg-warm: #f5f0e6;
  --panel-text: #3a3028;
  --panel-text-light: #6a5e50;
  --panel-border: #d8ccb8;
  --panel-line: #e8e0d4;
  --pink-warm: #c0a070;
  --pink-deep: #8a6840;
}

/* ========== 主题：雾灰（低对比度护眼） ========== */
body[data-theme="mist"] {
  --bg-deep: #1c1c20;
  --bg-mid: #28282e;
  --bg-glow: #383840;
  --dream-purple: #8890a0;
  --dream-light: #b0b8c8;
  --dream-glow: rgba(136, 144, 160, 0.3);
  --dream-pink: #a8b0c0;
  --dream-blue: #98a8b8;
  --panel-bg: #f4f4f6;
  --panel-bg-warm: #eeeef0;
  --panel-text: #2c2c30;
  --panel-text-light: #5a5a60;
  --panel-border: #cccfd4;
  --panel-line: #e0e0e4;
  --pink-warm: #888a90;
  --pink-deep: #5a5c62;
}

/* ========== 主题：墨水蓝（深邃护眼） ========== */
body[data-theme="ink"] {
  --bg-deep: #0f1419;
  --bg-mid: #1a2028;
  --bg-glow: #242d38;
  --dream-purple: #5a7a9a;
  --dream-light: #8aacc8;
  --dream-glow: rgba(90, 122, 154, 0.3);
  --dream-pink: #7a9ab8;
  --dream-blue: #a0c0d8;
  --panel-bg: #f0f3f6;
  --panel-bg-warm: #e8edf2;
  --panel-text: #1a2028;
  --panel-text-light: #4a5560;
  --panel-border: #c0ccd6;
  --panel-line: #d8e0e8;
  --pink-warm: #5a8098;
  --pink-deep: #3a5870;
}

/* ========== 主题：莫兰迪粉灰（柔和护眼） ========== */
body[data-theme="morandi"] {
  --bg-deep: #1a1a1e;
  --bg-mid: #26262c;
  --bg-glow: #36363e;
  --dream-purple: #a08898;
  --dream-light: #c8b8c4;
  --dream-glow: rgba(160, 136, 152, 0.3);
  --dream-pink: #bca8b4;
  --dream-blue: #a0a8b4;
  --panel-bg: #f5f2f4;
  --panel-bg-warm: #efebef;
  --panel-text: #302c30;
  --panel-text-light: #5e585e;
  --panel-border: #d4ccd4;
  --panel-line: #e4dee4;
  --pink-warm: #989098;
  --pink-deep: #6a626a;
}

/* ========== 字体大小 ========== */
body[data-font-size="small"] {
  --fs-body: 13px;
  --fs-panel: 11px;
  --fs-title: 18px;
  --fs-meta: 10px;
}
body[data-font-size="medium"] {
  --fs-body: 15px;
  --fs-panel: 12px;
  --fs-title: 22px;
  --fs-meta: 11px;
}
body[data-font-size="large"] {
  --fs-body: 17px;
  --fs-panel: 14px;
  --fs-title: 26px;
  --fs-meta: 12px;
}

/* ========== 背景模式 ========== */
body[data-bg-mode="pure"] {
  background: var(--bg-deep) !important;
}

body[data-bg-mode="starfield"] {
  background:
    radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.3), transparent),
    radial-gradient(2px 2px at 60px 70px, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.4), transparent),
    radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 160px 30px, rgba(255,255,255,0.3), transparent),
    radial-gradient(ellipse at 20% 30%, var(--bg-glow) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, var(--bg-glow) 0%, transparent 50%),
    var(--bg-deep);
  background-attachment: fixed;
}

/* 自定义背景图片模式 — 图片在整个页面背景（聊天区背后） */
body[data-bg-mode="custom"] {
  background-image: var(--custom-bg-image, none) !important;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
}
/* 自定义背景时给正文卡片加半透明底，保证可读性 */
body[data-bg-mode="custom"] .narrative-card {
  background: rgba(248, 244, 255, 0.92) !important;
  backdrop-filter: blur(4px);
}
/* 自定义背景时聊天区透明，露出后面背景图 */
body[data-bg-mode="custom"] .chat-container,
body[data-bg-mode="custom"] .chat-section {
  background: transparent !important;
}

/* ========== 全局重置 ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Serif SC', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: var(--fs-body);
  line-height: 1.8;
  background: var(--bg-deep);
  color: var(--panel-text);
}

body {
  background:
    radial-gradient(ellipse at 20% 30%, #3a2070 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, #4a2080 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, #2d1a4a 0%, #1a0a30 70%, #0e0520 100%);
  background-attachment: fixed;
}

/* ========== App Layout ========== */
.app-layout {
  display: flex;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* ========== Drawer (Left) ========== */
.drawer {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--drawer-width);
  background: var(--bg-mid);
  border-right: 1px solid rgba(200, 152, 240, 0.2);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 120;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 115;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.drawer.open ~ .drawer-backdrop,
.drawer-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(144, 96, 208, 0.15);
  border-bottom: 1px solid rgba(200, 152, 240, 0.2);
  flex-shrink: 0;
}

.drawer-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dream-light);
}

.drawer-close {
  background: none;
  border: none;
  color: var(--dream-light);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.drawer-close:hover {
  background: rgba(200, 152, 240, 0.15);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.drawer-placeholder {
  text-align: center;
  color: rgba(200, 152, 240, 0.3);
  padding: 40px 20px;
  font-size: 13px;
}

.drawer-footer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(200, 152, 240, 0.15);
  flex-shrink: 0;
}

.drawer-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(200, 152, 240, 0.2);
  border-radius: 8px;
  padding: 8px;
  color: var(--dream-light);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.drawer-btn:hover {
  background: rgba(200, 152, 240, 0.2);
  border-color: rgba(200, 152, 240, 0.4);
}

/* Memory entry cards in drawer */
.mem-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(200, 152, 240, 0.15);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.mem-card:hover {
  border-color: rgba(200, 152, 240, 0.3);
}

.mem-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--dream-light);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mem-card-group {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(144, 96, 208, 0.2);
  color: var(--dream-light);
}

.mem-card-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 4px;
}

.mem-kw {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(244, 143, 177, 0.12);
  color: var(--pink-warm);
}

.mem-card-content {
  font-size: 12px;
  color: #b8a8d0;
  line-height: 1.6;
}

.mem-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.mem-card-btn {
  background: rgba(200, 152, 240, 0.1);
  border: 1px solid rgba(200, 152, 240, 0.2);
  border-radius: 6px;
  padding: 3px 10px;
  color: var(--dream-light);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.mem-card-btn:hover {
  background: rgba(200, 152, 240, 0.2);
  border-color: rgba(200, 152, 240, 0.4);
}

.mem-card-btn-del {
  color: var(--pink-warm);
  border-color: rgba(244, 143, 177, 0.2);
}

.mem-card-btn-del:hover {
  background: rgba(244, 143, 177, 0.15);
  border-color: rgba(244, 143, 177, 0.4);
}

.mem-card-time {
  font-size: 10px;
  color: rgba(200, 152, 240, 0.3);
  margin-top: 4px;
}

/* 记忆状态指示器 */
.mem-status {
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
  line-height: 1.4;
}
.mem-status-ok {
  background: rgba(129, 199, 132, 0.1);
  color: #81c784;
  border: 1px solid rgba(129, 199, 132, 0.2);
}
.mem-status-skip {
  background: rgba(200, 152, 240, 0.08);
  color: rgba(200, 152, 240, 0.5);
  border: 1px solid rgba(200, 152, 240, 0.1);
}
.mem-status-err {
  background: rgba(244, 143, 177, 0.1);
  color: var(--pink-warm);
  border: 1px solid rgba(244, 143, 177, 0.2);
}

/* ========== Center: Chat Section ========== */
.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

/* Top Bar */
.top-bar {
  height: var(--top-bar-height);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: rgba(26, 16, 48, 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(200, 152, 240, 0.15);
  flex-shrink: 0;
  z-index: 50;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(200, 152, 240, 0.2);
  color: var(--dream-light);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: rgba(200, 152, 240, 0.2);
  border-color: rgba(200, 152, 240, 0.4);
}

/* 修复状态栏按钮 — 醒目样式 */
.repair-btn {
  background: rgba(255, 180, 80, 0.15);
  border-color: rgba(255, 180, 80, 0.5);
  color: #ffb450;
  animation: repair-pulse 2s ease-in-out infinite;
}
.repair-btn:hover {
  background: rgba(255, 180, 80, 0.3);
  border-color: rgba(255, 180, 80, 0.8);
  transform: scale(1.1);
}
.repair-btn.loading {
  animation: none;
  opacity: 0.6;
  pointer-events: none;
}
@keyframes repair-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 180, 80, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(255, 180, 80, 0); }
}

.scene-bar {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow: hidden;
  padding: 0 4px;
}

.scene-bar:empty::before {
  content: '与星同行';
  color: rgba(200, 152, 240, 0.3);
  font-size: 13px;
  align-self: center;
}

.scene-item {
  font-size: var(--fs-meta);
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--dream-light);
  white-space: nowrap;
  border: 1px solid rgba(200, 152, 240, 0.2);
}

/* Chat Container */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 20px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.chat-empty {
  text-align: center;
  color: rgba(200, 152, 240, 0.4);
  padding: 80px 20px;
  font-size: 14px;
}

/* ========== Messages ========== */
.message {
  margin-bottom: 16px;
  position: relative;
}

.message-user {
  text-align: right;
}

.message-user .bubble {
  display: inline-block;
  background: var(--dream-purple);
  color: #fff;
  padding: 10px 16px;
  border-radius: 16px 16px 4px 16px;
  max-width: 80%;
  text-align: left;
  font-size: var(--fs-body);
  line-height: 1.6;
  word-break: break-word;
}

.message-ai .bubble {
  display: block;
  width: 100%;
}

/* Narrative card (AI text) */
.narrative-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 4px 16px var(--panel-shadow);
  border: 1px solid var(--panel-border);
  font-size: var(--fs-body);
  line-height: 1.9;
  color: var(--panel-text);
  backdrop-filter: blur(8px);
}

.narrative-card p {
  margin-bottom: 12px;
  text-indent: 2em;
}

.narrative-card p:last-child {
  margin-bottom: 0;
}

/* Message toolbar */
.msg-toolbar {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  margin-top: 4px;
}

.message:hover .msg-toolbar {
  opacity: 1;
}

.message-user .msg-toolbar {
  justify-content: flex-end;
}

.message-ai .msg-toolbar {
  justify-content: flex-start;
}

.msg-btn {
  background: rgba(200, 152, 240, 0.1);
  border: 1px solid rgba(200, 152, 240, 0.2);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  color: rgba(200, 152, 240, 0.7);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.msg-btn:hover {
  background: rgba(200, 152, 240, 0.2);
  color: var(--dream-light);
  border-color: rgba(200, 152, 240, 0.4);
}

.msg-time {
  font-size: 10px;
  color: rgba(200, 152, 240, 0.3);
  margin-top: 2px;
}

/* ========== AI回复字数统计 ========== */
.msg-meta-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 4px;
}
.msg-word-count {
  font-size: 10px;
  color: rgba(200, 152, 240, 0.35);
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(200, 152, 240, 0.06);
}

/* System / Error messages */
.message-system .bubble {
  color: var(--dream-light);
  font-style: italic;
  font-size: 13px;
  padding: 8px 12px;
}

.message-error .bubble {
  color: var(--pink-warm);
  font-size: 13px;
  padding: 8px 12px;
}

/* ========== Input Area ========== */
.input-area {
  flex-shrink: 0;
  background: rgba(26, 16, 48, 0.95);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(200, 152, 240, 0.15);
  padding: 10px 16px;
}

.input-wrapper {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#messageInput {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(200, 152, 240, 0.3);
  border-radius: 12px;
  padding: 10px 16px;
  color: #e8ddf0;
  font-size: var(--fs-body);
  font-family: inherit;
  line-height: 1.6;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  transition: border-color 0.25s;
}

#messageInput::placeholder {
  color: rgba(200, 152, 240, 0.4);
}

#messageInput:focus {
  outline: none;
  border-color: var(--dream-light);
}

#messageInput:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#sendBtn {
  background: linear-gradient(135deg, var(--dream-purple), var(--dream-light));
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 20px;
  font-size: var(--fs-body);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}

#sendBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--dream-glow);
}

#sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

#sendBtn.abort-mode {
  background: linear-gradient(135deg, #e04050, #ff6070);
  animation: pulse-abort 1.5s ease-in-out infinite;
}

@keyframes pulse-abort {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 64, 80, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(224, 64, 80, 0); }
}

.input-meta {
  max-width: 720px;
  margin: 4px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 联网搜索本轮开关 */
.web-search-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: rgba(200, 152, 240, 0.6);
  transition: color 0.25s;
}

.web-search-toggle input[type="checkbox"] {
  display: none;
}

.web-search-toggle .toggle-slider {
  width: 32px;
  height: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  position: relative;
  transition: background 0.25s;
  flex-shrink: 0;
}

.web-search-toggle .toggle-slider::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(200, 152, 240, 0.5);
  top: 2px;
  left: 2px;
  transition: all 0.25s;
}

.web-search-toggle input:checked ~ .toggle-slider {
  background: linear-gradient(135deg, var(--dream-purple), var(--dream-light));
}

.web-search-toggle input:checked ~ .toggle-slider::after {
  left: 18px;
  background: #fff;
}

.web-search-toggle input:checked ~ .toggle-label {
  color: var(--dream-light);
}

.web-search-toggle:hover .toggle-label {
  color: var(--dream-light);
}

.web-search-toggle.active-pulse {
  animation: search-pulse 1s ease-in-out;
}

@keyframes search-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* 联网搜索自定义关键词输入框 */
.web-search-keyword {
  width: 130px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(200, 152, 240, 0.3);
  background: rgba(255, 255, 255, 0.06);
  color: var(--dream-light);
  font-size: 11px;
  padding: 0 8px;
  outline: none;
  transition: border-color 0.25s, width 0.25s;
}
.web-search-keyword::placeholder {
  color: rgba(200, 152, 240, 0.4);
}
.web-search-keyword:focus {
  border-color: var(--dream-light);
  width: 160px;
}

.text-btn {
  background: none;
  border: none;
  color: rgba(200, 152, 240, 0.4);
  font-size: var(--fs-meta);
  cursor: pointer;
  font-family: inherit;
  padding: 2px 6px;
}

.text-btn:hover {
  color: var(--dream-light);
}

#charCount {
  font-size: var(--fs-meta);
  color: rgba(200, 152, 240, 0.3);
}

/* ========== Left Panel (Protagonist) ========== */
.left-panel {
  width: var(--left-panel-width);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background: rgba(18, 22, 52, 0.7);
  border-right: 1px solid rgba(100, 140, 220, 0.15);
  flex-shrink: 0;
  height: 100vh;
}

.left-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(100, 140, 220, 0.08);
  border-bottom: 1px solid rgba(100, 140, 220, 0.15);
  flex-shrink: 0;
}

.left-panel-title {
  font-size: 13px;
  color: var(--dream-light);
  font-weight: 600;
  letter-spacing: 2px;
}

.left-panel-close {
  display: none;
  background: none;
  border: none;
  color: var(--dream-light);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
}

.left-panel-close:hover {
  background: rgba(255,255,255,0.1);
}

/* ========== Right Panel ========== */
.right-panel {
  width: var(--right-panel-width);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background: rgba(40, 18, 48, 0.7);
  border-left: 1px solid rgba(220, 140, 200, 0.15);
  flex-shrink: 0;
  height: 100vh;
}

.right-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(200, 100, 160, 0.08);
  border-bottom: 1px solid rgba(220, 140, 200, 0.15);
  flex-shrink: 0;
}

.right-panel-title {
  font-size: 13px;
  color: var(--dream-light);
  font-weight: 600;
  letter-spacing: 2px;
}

.right-panel-close {
  display: none;
  background: none;
  border: none;
  color: var(--dream-light);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
}

.right-panel-close:hover {
  background: rgba(255,255,255,0.1);
}

.panel-placeholder {
  text-align: center;
  color: rgba(200, 152, 240, 0.35);
  padding: 40px 20px;
  font-size: 13px;
}

.panel-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200, 152, 240, 0.3), transparent);
  flex-shrink: 0;
}

/* ========== Star Section (Right Top) ========== */
.star-section {
  flex: 0 0 auto;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.star-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(220, 140, 200, 0.15);
  background: rgba(200, 100, 160, 0.08);
}

.star-tab {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(200, 152, 240, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: var(--dream-light);
  font-size: var(--fs-panel);
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.star-tab:hover {
  background: rgba(200, 152, 240, 0.15);
}

.star-tab.active {
  background: linear-gradient(135deg, var(--dream-purple), var(--dream-light));
  color: #fff;
  border-color: var(--dream-purple);
  font-weight: 600;
}

.star-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* Star name */
.star-name-display {
  font-family: 'Ma Shan Zheng', 'Noto Serif SC', serif;
  font-size: var(--fs-title);
  color: var(--dream-light);
  text-shadow: 0 0 8px rgba(144, 96, 208, 0.4);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.star-meta {
  text-align: center;
  font-size: var(--fs-meta);
  color: rgba(200, 152, 240, 0.5);
  margin-bottom: 12px;
}

/* Star avatar */
.star-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 8px;
  background-size: cover;
  background-position: center top;
  border: 2px solid rgba(144, 96, 208, 0.4);
  box-shadow: 0 0 16px rgba(144, 96, 208, 0.3);
}

/* 头像放大模式 — 显示完整图片不裁剪 */
.star-avatar-large {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  margin: 0 auto 8px;
  border-radius: 10px;
  border: 2px solid rgba(144, 96, 208, 0.3);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* ========== Body Silhouette ========== */
.body-silhouette-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 12px;
}

/* 图片剪影容器 */
.silhouette-img-container {
  position: relative;
  width: 140px;
  height: 320px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.body-silhouette-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(144, 96, 208, 0.25));
  opacity: 0.85;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* 红点容器（百分比定位） */
.body-dot-wrapper {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
}

/* 脉冲环（CSS版） */
.body-pulse-ring-css {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--hot-red);
  transform: translate(-50%, -50%);
  animation: pulse-ring-css 1.5s ease-out infinite;
  pointer-events: none;
}

@keyframes pulse-ring-css {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(2.8); opacity: 0; }
}

/* 红点（CSS版） */
.body-dot-css {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--hot-red);
  border: 1.5px solid #fff;
  cursor: pointer;
  transition: all 0.2s;
  filter: drop-shadow(0 0 4px rgba(255, 68, 68, 0.7));
  z-index: 1;
}

.body-dot-css:hover {
  transform: scale(1.4);
  background: var(--hot-red-light);
}

.body-dot-css.active {
  background: var(--dream-purple);
  border-color: var(--dream-light);
  border-width: 2px;
  filter: drop-shadow(0 0 6px rgba(144, 96, 208, 0.7));
}

/* 标签文字（CSS版） */
.body-label-css {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: rgba(200, 152, 240, 0.5);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.body-dot-css.active ~ .body-label-css {
  color: var(--dream-light);
  font-weight: 600;
}

/* 旧SVG样式保留兼容 */
.body-silhouette {
  width: 120px;
  height: auto;
  filter: drop-shadow(0 0 10px rgba(144, 96, 208, 0.2));
}

.body-outline {
  fill: rgba(144, 96, 208, 0.08);
  stroke: rgba(200, 152, 240, 0.35);
  stroke-width: 1;
  stroke-linejoin: round;
}

/* Pulsing red dots (SVG版，保留兼容) */
.body-pulse-ring {
  fill: none;
  stroke: var(--hot-red);
  stroke-width: 1.5;
  transform-box: fill-box;
  transform-origin: center;
  animation: pulse-ring 1.5s ease-out infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(2.8); opacity: 0; }
}

.body-dot {
  fill: var(--hot-red);
  stroke: #fff;
  stroke-width: 1;
  cursor: pointer;
  transform-box: fill-box;
  transform-origin: center;
  transition: all 0.2s;
  filter: drop-shadow(0 0 3px rgba(255, 68, 68, 0.6));
}

.body-dot:hover {
  transform: scale(1.4);
  fill: var(--hot-red-light);
}

.body-dot.active {
  fill: var(--dream-purple);
  stroke: var(--dream-light);
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(144, 96, 208, 0.7));
}

.body-label {
  font-size: 7px;
  fill: rgba(200, 152, 240, 0.5);
  pointer-events: none;
  user-select: none;
  text-anchor: middle;
}

.body-dot.active ~ .body-label {
  fill: var(--dream-light);
  font-weight: 600;
}

/* Body part description */
.body-desc-area {
  width: 100%;
  margin-top: 8px;
}

.body-desc-hint {
  font-size: 11px;
  color: rgba(200, 152, 240, 0.35);
  text-align: center;
  font-style: italic;
}

.body-desc {
  display: none;
  font-size: 12px;
  line-height: 1.7;
  color: #d8c8e8;
  padding: 8px 10px;
  background: rgba(244, 143, 177, 0.08);
  border-radius: 8px;
  border-left: 3px solid var(--pink-warm);
  animation: fadeInUp 0.3s ease;
}

.body-desc.show {
  display: block;
}

.body-desc b {
  color: var(--pink-warm);
  font-weight: 600;
  margin-right: 4px;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== Stat Bars ========== */
.stat-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: var(--fs-panel);
}

.stat-label {
  font-weight: 600;
  color: var(--dream-light);
  min-width: 50px;
  flex-shrink: 0;
}

.stat-track {
  flex: 1;
  min-width: 60px;
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.stat-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.stat-value {
  font-size: 11px;
  color: rgba(200, 152, 240, 0.6);
  white-space: nowrap;
  min-width: 55px;
  text-align: right;
}

/* ========== Info Rows ========== */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 0;
  font-size: var(--fs-panel);
}

.info-label {
  color: var(--dream-light);
  font-weight: 600;
  flex-shrink: 0;
}

.info-value {
  color: #d8c8e8;
  text-align: right;
  word-break: break-word;
}

/* Sub-section title */
.sub-title {
  font-size: var(--fs-panel);
  font-weight: 700;
  color: var(--pink-warm);
  margin: 10px 0 4px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(244, 143, 177, 0.15);
}

/* ========== Protagonist Section (Left Panel) ========== */
.protagonist-section {
  flex: 0 0 auto;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.protagonist-header {
  padding: 8px 12px;
  font-size: var(--fs-panel);
  font-weight: 700;
  color: var(--dream-light);
  background: rgba(80, 120, 200, 0.12);
  border-bottom: 1px solid rgba(100, 140, 220, 0.15);
  flex-shrink: 0;
}

.protagonist-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
}

.protag-name {
  font-size: var(--fs-body);
  font-weight: 700;
  color: var(--dream-light);
  margin-bottom: 6px;
}

.protag-meta {
  font-size: 11px;
  color: rgba(200, 152, 240, 0.5);
  margin-bottom: 8px;
}

/* ========== Loading Dots ========== */
.loading-dots {
  display: inline-flex;
  gap: 4px;
  padding: 12px 16px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dream-light);
  animation: bounce 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ========== Suggestions ========== */
.suggestions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.suggestion-btn {
  flex: 1;
  min-width: 100px;
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--dream-light);
  font-size: var(--fs-panel);
  font-weight: 500;
  line-height: 1.5;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
  border: 1px solid rgba(200, 152, 240, 0.2);
}

.suggestion-btn:hover {
  transform: translateY(-2px);
  background: rgba(144, 96, 208, 0.2);
  border-color: rgba(200, 152, 240, 0.4);
  box-shadow: 0 4px 12px rgba(144, 96, 208, 0.2);
}

/* ========== Toast ========== */
.copy-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dream-purple);
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 500;
  animation: toastFade 1.5s ease forwards;
}

.copy-toast.toast-success {
  background: #2d8a4e;
}

.copy-toast.toast-warn {
  background: #c77f1a;
}

.copy-toast.toast-info {
  background: #3a6db5;
}

@keyframes toastFade {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  20% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ========== Settings Panel ========== */
.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 180;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.settings-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

#settingsPanel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-mid);
  border-left: 1px solid var(--dream-glow);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  transition: right 0.3s ease;
  overflow-y: auto;
  z-index: 200;
}

#settingsPanel.open { right: 0; }

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  margin: -20px -20px 16px;
  background: rgba(144, 96, 208, 0.15);
  border-bottom: 1px solid rgba(200, 152, 240, 0.2);
}

.settings-header span {
  font-size: 18px;
  font-weight: 700;
  color: var(--dream-light);
}

.settings-close-btn {
  background: none;
  border: none;
  color: var(--dream-light);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.settings-close-btn:hover {
  background: rgba(200, 152, 240, 0.15);
}

.settings-content {
  padding: 20px;
}

/* ========== 可折叠设置分类 ========== */
.settings-category {
  margin-bottom: 16px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(200, 152, 240, 0.15);
}

.settings-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(144, 96, 208, 0.12);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.settings-category-header:hover {
  background: rgba(144, 96, 208, 0.2);
}

.settings-category-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dream-light);
}

.settings-category-arrow {
  font-size: 12px;
  color: var(--dream-light);
  transition: transform 0.3s;
  display: inline-block;
}

.settings-category.collapsed .settings-category-arrow {
  transform: rotate(-90deg);
}

.settings-category-body {
  padding: 4px 16px 16px;
  max-height: 9999px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
  opacity: 1;
}

.settings-category.collapsed .settings-category-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

.settings-section {
  margin-bottom: 20px;
}

.settings-section h3 {
  color: var(--dream-light);
  font-size: 14px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(200, 152, 240, 0.15);
}

.settings-section label,
.api-config-fields label,
.settings-sub-body label {
  display: block;
  color: var(--dream-light);
  font-size: 13px;
  margin: 8px 0 4px;
}

.settings-section input,
.settings-section select,
.api-config-fields input[type="text"],
.api-config-fields input[type="password"],
.api-config-fields select,
.settings-sub-body input[type="text"],
.settings-sub-body input[type="password"],
.settings-sub-body select {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(200, 152, 240, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  color: #e8ddf0;
  font-size: 14px;
  font-family: inherit;
}

.settings-section input:focus,
.api-config-fields input:focus,
.api-config-fields select:focus,
.settings-sub-body input:focus,
.settings-sub-body select:focus {
  outline: none;
  border-color: var(--dream-light);
}

.settings-btn {
  background: linear-gradient(135deg, var(--dream-purple), var(--dream-light));
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 8px;
}

.settings-btn-outline {
  background: transparent;
  border: 1px solid rgba(200, 152, 240, 0.4);
  color: var(--dream-light);
}

.settings-save-btn {
  width: 100%;
  margin-top: 12px;
}

.api-test-result {
  display: block;
  font-size: 12px;
  margin-top: 6px;
  min-height: 16px;
}

.api-test-result.ok { color: #81c784; }
.api-test-result.fail { color: #f48fb1; }
.api-test-result.loading { color: var(--dream-light); }

/* API Preset Buttons */
.api-presets {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.api-preset-btn {
  font-size: 11px !important;
  padding: 4px 10px !important;
  flex: 1;
  min-width: 60px;
  white-space: nowrap;
}

/* ========== API Tab 切换栏 ========== */
.api-tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  border-bottom: 2px solid rgba(200, 152, 240, 0.15);
}
.api-tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--dream-light);
  opacity: 0.5;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -2px;
}
.api-tab:hover {
  opacity: 0.8;
  background: rgba(144, 96, 208, 0.08);
}
.api-tab.active {
  opacity: 1;
  border-bottom-color: var(--dream-light);
  color: var(--dream-light);
}

/* API配置区域 */
.api-config-fields {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}
.api-config-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.api-tab-extra {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(200, 152, 240, 0.15);
}

/* ========== 字段网格（双列布局） ========== */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.field-grid .field-row {
  margin-bottom: 0;
}
.field-row {
  margin-bottom: 10px;
}
.field-row label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--dream-light);
  font-size: 13px;
  margin: 0 0 4px;
}
.field-hint {
  font-size: 10px;
  color: #9e9e9e;
  font-weight: 400;
}
.settings-hint {
  font-size: 11px;
  color: #9e9e9e;
  display: block;
  margin: 4px 0 8px;
  line-height: 1.4;
}

/* ========== 统一 textarea 样式 ========== */
.settings-textarea {
  width: 100%;
  margin-bottom: 6px;
  height: 60px;
  resize: vertical;
  background: rgba(255, 255, 255, 0.08);
  color: #e8ddf0;
  border: 1px solid rgba(200, 152, 240, 0.3);
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  font-family: monospace;
}
.settings-textarea:focus {
  outline: none;
  border-color: var(--dream-light);
}

/* ========== 可折叠子区域 ========== */
.settings-sub-collapse {
  margin-top: 10px;
  border: 1px solid rgba(200, 152, 240, 0.1);
  border-radius: 8px;
  overflow: hidden;
}
.settings-sub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(144, 96, 208, 0.08);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--dream-light);
  transition: background 0.2s;
}
.settings-sub-header:hover {
  background: rgba(144, 96, 208, 0.14);
}
.settings-sub-arrow {
  font-size: 10px;
  transition: transform 0.3s;
  display: inline-block;
}
.settings-sub-collapse.collapsed .settings-sub-arrow {
  transform: rotate(-90deg);
}
.settings-sub-body {
  padding: 12px 14px;
  max-height: 9999px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
  opacity: 1;
}
.settings-sub-collapse.collapsed .settings-sub-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

/* 移动端：字段网格单列 */
@media (max-width: 480px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
  .api-tab {
    font-size: 11px;
    padding: 8px 4px;
  }
}

/* ========== Memory Manager Panel ========== */
.memory-manager-panel {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 300;
  overflow-y: auto;
}

.memory-manager-inner {
  max-width: 600px;
  margin: 40px auto;
  background: var(--bg-mid);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid rgba(200, 152, 240, 0.3);
}

.memory-manager-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.memory-manager-header h3 {
  color: var(--dream-light);
  font-size: 16px;
}

.memory-manager-close {
  background: none;
  border: none;
  color: var(--dream-light);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.memory-manager-close:hover {
  background: rgba(200, 152, 240, 0.15);
}

.memory-list-area {
  margin-bottom: 16px;
}

.memory-add-section {
  border-top: 1px solid rgba(200, 152, 240, 0.2);
  padding-top: 16px;
}

.memory-add-section h4 {
  color: var(--dream-light);
  font-size: 14px;
  margin-bottom: 8px;
}

.mem-input {
  width: 100%;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(200, 152, 240, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  color: #e8ddf0;
  font-size: 14px;
  font-family: inherit;
}

.mem-textarea {
  min-height: 80px;
  resize: vertical;
}

.mem-btn-row {
  display: flex;
  gap: 8px;
}

/* ========== Mobile Panel Toggle ========== */
.mobile-panel-toggle {
  display: none;
}

.mobile-left-toggle {
  display: none;
}

.right-panel-backdrop {
  display: none;
}

.left-panel-backdrop {
  display: none;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(200, 152, 240, 0.2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(200, 152, 240, 0.4);
}

/* ========== Responsive ========== */
@media (max-width: 900px) {
  .right-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 200;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .right-panel.open {
    transform: translateX(0);
  }

  /* 移动端显示关闭按钮 */
  .right-panel-close,
  .left-panel-close {
    display: block;
  }

  .left-panel {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .left-panel.open {
    transform: translateX(0);
  }

  .mobile-panel-toggle {
    display: flex;
    position: fixed;
    bottom: 80px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--dream-purple);
    color: #fff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    z-index: 90;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--dream-glow);
  }

  .mobile-left-toggle {
    display: flex;
    position: fixed;
    bottom: 80px;
    left: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--dream-purple);
    color: #fff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    z-index: 90;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--dream-glow);
  }

  .right-panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 195;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }

  .left-panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 195;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }

  .right-panel.open ~ .right-panel-backdrop,
  .right-panel-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }

  .left-panel.open ~ .left-panel-backdrop,
  .left-panel-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 600px) {
  :root {
    --drawer-width: 260px;
  }

  .chat-container {
    padding: 12px 8px;
  }

  .narrative-card {
    padding: 16px 14px;
    font-size: var(--fs-body);
  }

  .scene-bar {
    gap: 4px;
  }

  .scene-item {
    font-size: var(--fs-meta);
    padding: 2px 8px;
  }

  .suggestions {
    flex-direction: column;
  }

  .suggestion-btn {
    min-width: 100%;
  }

  .body-silhouette {
    width: 100px;
  }
}

/* ========== 角色编辑面板 ========== */
.char-edit-panel {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 10002;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 30px 0;
  overflow-y: auto;
}
.char-edit-panel.open { display: flex; }

.char-edit-inner {
  background: var(--dream-bg2, #1a1528);
  border: 1px solid rgba(200,152,240,0.2);
  border-radius: 16px;
  width: 540px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.char-edit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(200,152,240,0.1);
  position: sticky;
  top: 0;
  background: var(--dream-bg2, #1a1528);
  z-index: 1;
  border-radius: 16px 16px 0 0;
}
.char-edit-header h3 { font-size: 16px; color: #e8ddf0; margin: 0; }
.char-edit-close {
  background: none; border: none;
  color: #9a98aa; font-size: 18px; cursor: pointer;
}
.char-edit-body { padding: 12px 18px; }
.char-edit-section {
  margin: 12px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(200,152,240,0.1);
}
.char-edit-section h4 { font-size: 13px; color: #c898f0; margin: 0; }
.char-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.ce-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ce-field label {
  font-size: 11px;
  color: #9a98aa;
}
.ce-field input, .ce-field select {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(200,152,240,0.15);
  border-radius: 6px;
  padding: 6px 8px;
  color: #e8ddf0;
  font-size: 12px;
}
.ce-field input:focus, .ce-field select:focus {
  border-color: rgba(200,152,240,0.5);
  outline: none;
}
.ce-full {
  margin: 8px 0;
}
.ce-full label {
  font-size: 11px;
  color: #9a98aa;
  display: block;
  margin-bottom: 3px;
}
.ce-full textarea {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(200,152,240,0.15);
  border-radius: 6px;
  padding: 8px;
  color: #e8ddf0;
  font-size: 12px;
  min-height: 60px;
  resize: vertical;
}
.ce-full textarea:focus {
  border-color: rgba(200,152,240,0.5);
  outline: none;
}
.char-edit-footer {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 12px 18px 16px;
  border-top: 1px solid rgba(200,152,240,0.1);
  position: sticky;
  bottom: 0;
  background: var(--dream-bg2, #1a1528);
  border-radius: 0 0 16px 16px;
}

/* ========== 搜索日志区（右侧栏底部） ========== */
.search-log-section {
  border-top: 1px solid rgba(200,152,240,0.15);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(18,12,28,0.8);
}
.search-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #c898f0;
  font-weight: 600;
}
.search-log-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.search-log-toggle input { display: none; }
.search-log-toggle .toggle-slider {
  width: 28px; height: 14px;
  background: #444;
  border-radius: 7px;
  position: relative;
  transition: background 0.2s;
}
.search-log-toggle .toggle-slider::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  background: #999;
  border-radius: 50%;
  top: 1px; left: 1px;
  transition: all 0.2s;
}
.search-log-toggle input:checked + .toggle-slider {
  background: rgba(200,152,240,0.6);
}
.search-log-toggle input:checked + .toggle-slider::after {
  background: #c898f0;
  left: 15px;
}
.search-log-keyword {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(200,152,240,0.15);
  border-radius: 6px;
  padding: 4px 8px;
  color: #e8ddf0;
  font-size: 11px;
}
.search-log-keyword:focus {
  border-color: rgba(200,152,240,0.4);
  outline: none;
}
.search-log-mode {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(200,152,240,0.15);
  border-radius: 6px;
  padding: 3px 6px;
  color: #9a98aa;
  font-size: 10px;
}
.search-log-body {
  max-height: 160px;
  overflow-y: auto;
  font-size: 10px;
  color: #9a98aa;
}
.search-log-empty {
  color: #5a5878;
  text-align: center;
  padding: 8px 0;
}
.search-log-entry {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.search-log-entry .sl-query {
  color: #c898f0;
  font-size: 10px;
}
.sl-clickable { cursor: pointer; }
.sl-clickable:hover { color: #e8b8ff; text-decoration: underline; }
.sl-detail {
  line-height: 1.3;
}
.search-log-entry .sl-status {
  font-size: 9px;
  color: #7a7898;
}
.search-log-entry .sl-result {
  font-size: 9px;
  color: #6a6888;
  margin-top: 2px;
}

.search-log-test {
  width: 100%;
  margin-top: 6px;
  padding: 4px 8px;
  background: rgba(200,152,240,0.12);
  border: 1px solid rgba(200,152,240,0.2);
  border-radius: 6px;
  color: #c898f0;
  font-size: 10px;
  cursor: pointer;
}
.search-log-test:hover { background: rgba(200,152,240,0.25); }

/* 移动端：搜索日志区 */
@media (max-width: 768px) {
  .search-log-section {
    border-top: 1px solid rgba(200,152,240,0.15);
    padding: 8px 10px;
  }
  .search-log-keyword { font-size: 10px; padding: 3px 6px; }
  .search-log-mode { font-size: 9px; }
  .search-log-body { max-height: 100px; }
}

/* ========== Message Edit Mode ========== */
.msg-edit-area {
  margin-bottom: 8px;
}

.msg-edit-textarea {
  width: 100%;
  min-height: 80px;
  max-height: 400px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid var(--dream-light);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.7;
  color: var(--panel-text);
  resize: vertical;
  outline: none;
}

.message-user .msg-edit-textarea {
  border-radius: 16px 16px 4px 16px;
}

.msg-edit-btns {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.message-user .msg-edit-btns {
  justify-content: flex-end;
}

.message-ai .msg-edit-btns {
  justify-content: flex-start;
}

.msg-btn-primary {
  background: var(--dream-purple) !important;
  color: #fff !important;
  border-color: var(--dream-purple) !important;
}

.msg-btn-primary:hover {
  background: var(--dream-light) !important;
}

.msg-btn-danger {
  color: var(--pink-warm) !important;
  border-color: rgba(244, 143, 177, 0.2) !important;
}

.msg-btn-danger:hover {
  background: rgba(244, 143, 177, 0.15) !important;
  border-color: rgba(244, 143, 177, 0.4) !important;
}

/* ========== Rollback Button (Top Bar) ========== */
#rollbackBtn {
  position: relative;
}

#rollbackBtn.has-snapshots {
  background: rgba(144, 96, 208, 0.25);
  border-color: rgba(200, 152, 240, 0.5);
}

.rollback-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--pink-deep);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 1.5px solid var(--bg-deep);
}

/* ========== Rollback Panel ========== */
.rollback-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 200;
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.rollback-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.rollback-panel-inner {
  background: var(--bg-mid);
  border: 1px solid rgba(200, 152, 240, 0.3);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.rollback-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(144, 96, 208, 0.15);
  border-bottom: 1px solid rgba(200, 152, 240, 0.2);
}

.rollback-panel-header h3 {
  font-size: 16px;
  color: var(--dream-light);
  font-weight: 700;
}

.rollback-panel-close {
  background: none;
  border: none;
  color: var(--dream-light);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.rollback-panel-close:hover {
  background: rgba(200, 152, 240, 0.15);
}

.rollback-panel-desc {
  padding: 12px 20px;
  font-size: 12px;
  color: rgba(200, 152, 240, 0.5);
  line-height: 1.6;
  border-bottom: 1px solid rgba(200, 152, 240, 0.1);
}

.rollback-list {
  overflow-y: auto;
  padding: 12px;
  flex: 1;
}

.rollback-empty {
  text-align: center;
  color: rgba(200, 152, 240, 0.3);
  padding: 40px 20px;
  font-size: 14px;
}

.rollback-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(200, 152, 240, 0.15);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.rollback-item:hover {
  border-color: rgba(200, 152, 240, 0.3);
}

.rollback-item-info {
  flex: 1;
  min-width: 0;
}

.rollback-item-round {
  font-size: 13px;
  font-weight: 600;
  color: var(--dream-light);
  margin-bottom: 3px;
}

.rollback-item-preview {
  font-size: 12px;
  color: rgba(200, 152, 240, 0.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rollback-item-btn {
  background: var(--dream-purple);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  margin-left: 10px;
  transition: all 0.2s;
}

.rollback-item-btn:hover {
  background: var(--dream-light);
  transform: translateY(-1px);
}

/* ========== Archive Panel ========== */
.archive-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 200;
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.archive-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.archive-panel-inner {
  background: var(--bg-mid);
  border: 1px solid rgba(200, 152, 240, 0.3);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.archive-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(144, 96, 208, 0.15);
  border-bottom: 1px solid rgba(200, 152, 240, 0.2);
}

.archive-panel-header h3 {
  font-size: 16px;
  color: var(--dream-light);
  font-weight: 700;
}

.archive-panel-close {
  background: none;
  border: none;
  color: var(--dream-light);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.archive-panel-close:hover {
  background: rgba(200, 152, 240, 0.15);
}

.archive-panel-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(200, 152, 240, 0.1);
}

.archive-list-container {
  overflow-y: auto;
  padding: 12px;
  flex: 1;
}

.archive-empty {
  text-align: center;
  color: rgba(200, 152, 240, 0.3);
  padding: 40px 20px;
  font-size: 14px;
}

.archive-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(200, 152, 240, 0.15);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.archive-card.active {
  border-color: var(--dream-light);
  background: rgba(144, 96, 208, 0.12);
}

.archive-card:hover {
  border-color: rgba(200, 152, 240, 0.3);
}

.archive-card-info {
  flex: 1;
  min-width: 0;
}

.archive-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--dream-light);
  margin-bottom: 3px;
}

.archive-active-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--dream-purple);
  color: #fff;
  vertical-align: middle;
  margin-left: 4px;
}

/* =========================================
   Social Panel — 社媒面板
   ========================================= */

/* 社媒按钮锁定状态 */
#socialToggleBtn.social-locked {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 社媒面板容器 — 居中简报面板 */
.social-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0;
  pointer-events: none;
  width: 92%;
  max-width: 960px;
  height: 88vh;
  background: var(--social-panel-bg);
  z-index: 1000;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  display: flex;
  flex-direction: column;
}

.social-panel.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.social-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.social-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--social-header-bg);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.social-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.social-panel-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--social-header-text);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.social-entry-meta {
  font-size: 12px;
  color: #888;
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  flex-wrap: wrap;
}

.social-entry-meta .meta-badge {
  background: rgba(144, 96, 208, 0.2);
  color: #c8a8e8;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  white-space: nowrap;
}

.social-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.social-panel-close {
  background: none;
  border: none;
  color: #999;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.social-panel-close:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* 简报主体 — masonry瀑布流 */
.social-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  background: var(--social-body-bg);
  column-count: 3;
  column-gap: 14px;
  column-fill: balance;
}

@media (max-width: 1100px) {
  .social-panel-body { column-count: 2; }
}

@media (max-width: 600px) {
  .social-panel-body { column-count: 1; padding: 12px; }
}

/* 空状态 */
.social-empty {
  text-align: center;
  color: #555;
  font-size: 14px;
  padding: 40px 20px;
  column-span: all;
}

.social-empty-hint {
  font-size: 12px;
  color: #444;
  display: block;
  margin-top: 8px;
}

/* 加载动画 */
.social-loading {
  text-align: center;
  padding: 40px 20px;
  column-span: all;
}

.social-loading-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}

.social-loading-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #888;
  animation: social-bounce 1.4s infinite ease-in-out both;
}

.social-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.social-loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes social-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.social-loading-text {
  color: #888;
  font-size: 13px;
}

/* 错误提示 */
.social-error {
  text-align: center;
  padding: 30px 20px;
  column-span: all;
}

.social-error-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.social-error-text {
  color: #ff6b6b;
  font-size: 13px;
  line-height: 1.5;
}

/* 翻页导航 */
.social-panel-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  background: #1a1a20;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(200,152,240,0.3) transparent;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}
.social-panel-nav::-webkit-scrollbar {
  height: 3px;
}
.social-panel-nav::-webkit-scrollbar-track {
  background: transparent;
}
.social-panel-nav::-webkit-scrollbar-thumb {
  background: rgba(200,152,240,0.3);
  border-radius: 2px;
}
.social-panel-nav .settings-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.social-nav-info {
  font-size: 12px;
  color: #888;
  flex-shrink: 0;
  white-space: nowrap;
}

/* =========================================
   社媒回复互动区域
   ========================================= */

/* 卡片+回复的包裹容器，防止masonry拆散 */
.social-item-wrapper {
  break-inside: avoid;
  display: inline-block;
  width: 100%;
  margin-bottom: 14px;
}

/* 回复区域紧贴卡片底部，视觉上属于同一张卡片 */
.social-reply-section {
  margin-top: -2px;
  padding: 10px 14px 12px;
  background: var(--social-reply-section-bg);
  border-top: 1px solid rgba(255,255,255,0.06);
  border-radius: 0 0 8px 8px;
}

/* 卡片底部圆角去掉，与回复区域无缝衔接 */
.social-item-wrapper .media-card {
  border-radius: 8px 8px 0 0;
  margin-bottom: 0;
}

/* 没有回复区域时卡片保持完整圆角 */
.social-item-wrapper .media-card:last-child {
  border-radius: 8px;
  margin-bottom: 14px;
}

.social-reply {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.social-reply-player {
  background: var(--social-player-bg);
  color: var(--social-player-text);
  padding: 6px 10px;
  border-radius: 6px;
  border-left: 2px solid var(--social-player-border);
}

.social-reply-npc {
  color: var(--social-npc-text);
  padding: 4px 0;
}

.reply-icon {
  font-size: 12px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.reply-author {
  font-weight: 600;
  color: var(--social-npc-author);
  min-width: 50px;
  flex-shrink: 0;
}

.social-reply-player .reply-author {
  color: var(--social-player-author);
}

.reply-text {
  flex: 1;
  word-break: break-word;
  color: inherit;
}

.social-reply-input-area {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.social-reply-input {
  flex: 1;
  background: var(--social-input-bg);
  border: 1px solid var(--social-input-border);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--social-input-text);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.social-reply-input:focus {
  border-color: #5b8ff9;
}

.social-reply-input::placeholder {
  color: var(--social-input-placeholder);
}

.social-reply-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.social-reply-btn {
  background: var(--social-btn-bg);
  color: var(--social-btn-text);
  border: none;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.social-reply-btn:hover:not(:disabled) {
  background: #4a7fe8;
}

.social-reply-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =========================================
   媒体卡片 — 各类型独立风格（masonry简报布局）
   报纸 / CRT显示屏 / 手机App / BBS终端 / 门户网页
   ========================================= */

.media-card {
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.6;
  overflow: hidden;
  break-inside: avoid;
  display: inline-block;
  width: 100%;
  animation: cardFadeIn 0.4s ease both;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.media-card:hover {
  transform: translateY(-2px);
  z-index: 2;
  position: relative;
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══ 报纸风格 — 复古报纸质感 ═══ */
.media-newspaper {
  background:
    repeating-linear-gradient(0deg, transparent, transparent 28px, rgba(139,109,71,0.03) 28px, rgba(139,109,71,0.03) 29px),
    linear-gradient(135deg, #f5ecd6 0%, #ece0c4 50%, #f0e4c8 100%);
  color: #1a1208;
  border: 1px solid #c8b888;
  border-top: 3px double #8a7050;
  border-bottom: 3px double #8a7050;
  font-family: 'Noto Serif SC', 'SimSun', serif;
  box-shadow: 0 1px 3px rgba(139,109,71,0.2), inset 0 0 20px rgba(139,109,71,0.05);
  position: relative;
}
.media-newspaper::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 20% 80%, rgba(139,109,71,0.06), transparent 60%);
  pointer-events: none;
}
.newspaper-masthead {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 2px solid #6a4f30; padding-bottom: 6px; margin-bottom: 8px;
}
.newspaper-name { font-size: 16px; font-weight: 700; letter-spacing: 2px; color: #1a1208; }
.newspaper-edition { font-size: 10px; color: #8a6f4a; font-style: italic; letter-spacing: 1px; }
.newspaper-divider { border-top: 1px solid #b8a070; border-bottom: 1px solid #b8a070; height: 3px; margin-bottom: 8px; }
.newspaper-headline { font-size: 17px; font-weight: 700; margin-bottom: 6px; line-height: 1.3; color: #0a0804; border-left: 3px solid #8a7050; padding-left: 8px; }
.newspaper-byline { font-size: 10px; color: #7a5f3a; margin-bottom: 8px; font-style: italic; }
.newspaper-body { font-size: 13px; text-align: justify; line-height: 1.7; color: #2a1a08; }
.newspaper-body::first-letter { font-size: 28px; font-weight: 700; float: left; line-height: 1; margin-right: 4px; margin-top: 2px; color: #6a4f20; }
.newspaper-tags { font-size: 10px; color: #9a7f50; margin-top: 8px; border-top: 1px dashed #c8b888; padding-top: 4px; }

/* ═══ 杂志风格 — 光泽封面 ═══ */
.media-magazine { background: #fff; color: #333; border-radius: 6px; overflow: hidden; border: 1px solid #e0e0e0; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.magazine-cover { background: linear-gradient(135deg, #e91e63 0%, #9c27b0 100%); padding: 14px; color: #fff; position: relative; }
.magazine-cover::after { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, rgba(255,255,255,0.15), transparent 40%); }
.magazine-name { font-size: 11px; opacity: 0.85; text-transform: uppercase; letter-spacing: 2px; font-weight: 600; }
.magazine-column { font-size: 16px; font-weight: 700; margin-top: 4px; text-shadow: 0 1px 4px rgba(0,0,0,0.3); }
.magazine-content { padding: 10px 14px; }
.magazine-author { font-size: 11px; color: #999; margin-bottom: 6px; letter-spacing: 1px; }
.magazine-text { font-size: 13px; line-height: 1.7; color: #444; }
.magazine-tags { margin-top: 8px; }
.mag-tag { display: inline-block; font-size: 10px; padding: 2px 8px; margin-right: 4px; border-radius: 10px; background: linear-gradient(135deg, rgba(233,30,99,0.1), rgba(156,39,176,0.1)); color: #c2185b; border: 1px solid rgba(233,30,99,0.15); }

/* ═══ 电视新闻 — CRT显示屏效果 ═══ */
.media-tv { background: #0a0a12; border-radius: 10px; padding: 6px; border: 2px solid #2a2a3a; box-shadow: 0 0 0 1px #1a1a28, 0 4px 12px rgba(0,0,0,0.5); }
.tv-screen { padding: 14px; background: radial-gradient(ellipse at center, #0d1525 0%, #050510 100%); border-radius: 6px; position: relative; overflow: hidden; min-height: 80px; }
.tv-screen::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,255,100,0.03) 2px, rgba(0,255,100,0.03) 3px); pointer-events: none; z-index: 1; }
.tv-screen::after { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.4) 100%); pointer-events: none; z-index: 2; }
.tv-channel { font-size: 10px; color: #ff4444; margin-bottom: 6px; letter-spacing: 1px; font-weight: 600; position: relative; z-index: 3; }
.tv-channel::before { content: '●'; margin-right: 4px; animation: tv-blink 1.5s infinite; }
@keyframes tv-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.tv-headline { font-size: 14px; font-weight: 700; color: #ffffff; margin-bottom: 8px; text-shadow: 0 0 6px rgba(255,255,255,0.3); position: relative; z-index: 3; }
.tv-ticker { font-size: 12px; color: #88ff88; line-height: 1.5; text-shadow: 0 0 4px rgba(136,255,136,0.3); position: relative; z-index: 3; }
.tv-time { font-size: 9px; color: #4a4a5a; margin-top: 8px; border-top: 1px solid #1a1a28; padding-top: 4px; position: relative; z-index: 3; }
.tv-stand { text-align: center; font-size: 16px; margin-top: 2px; opacity: 0.4; }

/* ═══ 电台风格 — 复古收音机 ═══ */
.media-radio { background: linear-gradient(135deg, #2a1f14 0%, #1a1408 100%); color: #ffb060; border: 1px solid #4a3820; border-radius: 8px; display: flex; gap: 12px; align-items: flex-start; box-shadow: inset 0 0 20px rgba(255,176,96,0.05); }
.radio-icon { font-size: 26px; flex-shrink: 0; filter: sepia(1) hue-rotate(-10deg) brightness(1.2); }
.radio-info { flex: 1; }
.radio-station { font-size: 11px; color: #ffb060; margin-bottom: 4px; letter-spacing: 1px; text-transform: uppercase; }
.radio-content { font-size: 13px; font-style: italic; color: #d4a060; line-height: 1.6; }
.radio-time { font-size: 10px; color: #8a6a3a; margin-top: 4px; }

/* ═══ 门户网站 — Web 1.0风格 ═══ */
.media-portal { background: #ffffff; color: #333; border: 1px solid #ccc; border-left: 4px solid #1a6cc7; font-family: 'Microsoft YaHei', 'SimSun', sans-serif; }
.portal-source { font-size: 11px; color: #888; margin-bottom: 4px; }
.portal-channel { color: #1a6cc7; margin-left: 4px; }
.portal-title { font-size: 15px; font-weight: 700; color: #1a6cc7; margin-bottom: 4px; text-decoration: underline; }
.portal-summary { font-size: 12px; color: #555; line-height: 1.6; }
.portal-meta { font-size: 10px; color: #aaa; margin-top: 6px; border-top: 1px dotted #ddd; padding-top: 4px; }

/* ═══ 论坛帖子 — BBS终端风格 ═══ */
.media-forum { background: #000a00; color: #33ff33; border: 1px solid #003300; border-radius: 4px; font-family: 'Courier New', 'Consolas', monospace; box-shadow: inset 0 0 15px rgba(51,255,51,0.05); }
.forum-header { font-size: 13px; font-weight: 700; margin-bottom: 6px; color: #00ff00; text-shadow: 0 0 4px rgba(0,255,0,0.3); }
.forum-board { color: #ffff00; }
.forum-meta { display: flex; gap: 12px; font-size: 10px; color: #00aa00; margin-bottom: 8px; flex-wrap: wrap; }
.forum-author { color: #ff8800; }
.forum-content { font-size: 12px; padding: 8px; background: rgba(0,255,51,0.03); border: 1px solid rgba(0,255,51,0.1); border-radius: 2px; color: #88ff88; line-height: 1.6; }
.forum-replies-list { margin-top: 8px; padding-left: 16px; }
.forum-reply { font-size: 11px; color: #00cc00; padding: 3px 0 3px 8px; border-left: 2px solid #004400; margin-bottom: 3px; opacity: 0.85; }

/* ═══ 博客风格 — 早期博客 ═══ */
.media-blog { background: linear-gradient(to bottom, #fffbf0, #fff5e0); color: #4a3a28; border: 1px solid #e0d0a0; border-radius: 6px; }
.blog-author { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px dashed #d0c090; }
.blog-avatar { font-size: 18px; }
.blog-name { font-size: 12px; font-weight: 600; color: #6a5a3a; }
.blog-platform { font-size: 10px; color: #aa9a7a; margin-left: auto; }
.blog-title { font-size: 15px; font-weight: 700; color: #3a2a18; margin-bottom: 6px; font-family: 'Noto Serif SC', serif; }
.blog-content { font-size: 13px; line-height: 1.7; color: #5a4a38; }
.blog-meta { font-size: 10px; color: #aa9a7a; margin-top: 8px; padding-top: 4px; border-top: 1px dashed #d0c090; }

/* ═══ 微博动态 — 手机App风格 ═══ */
.media-weibo-post { background: #ffffff; color: #333; border-radius: 10px; border: 1px solid #eee; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.weibo-user { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.weibo-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #ff8a80, #ff5252); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.weibo-user-info { display: flex; flex-direction: column; }
.weibo-name { font-size: 13px; font-weight: 600; color: #1a1a1a; }
.weibo-platform { font-size: 10px; color: #ff5252; }
.weibo-text { font-size: 14px; line-height: 1.6; color: #333; margin-bottom: 10px; }
.weibo-meta { display: flex; gap: 16px; font-size: 11px; color: #999; padding-top: 8px; border-top: 1px solid #f5f5f5; }
.weibo-time { margin-left: auto; color: #ccc; }

/* ═══ 微博热搜 — 排行榜样式 ═══ */
.media-hotsearch { background: #ffffff; border-radius: 8px; border: 1px solid #eee; padding: 8px 12px; }
.hotsearch-row { display: flex; align-items: center; gap: 10px; }
.hotsearch-rank { font-size: 16px; font-weight: 700; color: #ff5252; min-width: 24px; text-align: center; font-family: 'Arial', sans-serif; }
.hotsearch-rank.rank-top { color: #fff; background: linear-gradient(135deg, #ff5252, #d32f2f); border-radius: 4px; padding: 2px 6px; font-size: 13px; }
.hotsearch-title { flex: 1; font-size: 14px; font-weight: 500; color: #1a1a1a; }
.hotsearch-heat { font-size: 11px; color: #ff8a80; font-weight: 600; }
.hotsearch-tags { font-size: 10px; color: #aaa; margin-top: 4px; padding-left: 34px; }

/* ═══ 评论风向 — 情感标签 ═══ */
.media-comments { background: #fafafa; border-radius: 8px; border: 1px solid #eee; }
.comments-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.comments-platform { font-size: 13px; font-weight: 600; color: #333; }
.comments-sentiment { font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.sentiment-positive { background: #e8f5e9; color: #4caf50; }
.sentiment-negative { background: #ffebee; color: #f44336; }
.sentiment-mixed { background: #fff3e0; color: #ff9800; }
.sentiment-neutral { background: #f5f5f5; color: #999; }
.comments-topic { font-size: 13px; color: #555; margin-bottom: 8px; font-weight: 500; }
.comments-list { padding-left: 0; }
.comment-item { font-size: 12px; color: #666; padding: 4px 0; border-bottom: 1px solid #f0f0f0; line-height: 1.5; }
.comment-item:last-child { border-bottom: none; }

/* ═══ 超话 — 粉丝文化 ═══ */
.media-supertopic { background: linear-gradient(135deg, #fff0f5, #fff); border: 1px solid #ffcdd2; border-radius: 10px; }
.supertopic-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.supertopic-icon { font-size: 18px; }
.supertopic-name { font-size: 13px; font-weight: 700; color: #e91e63; }
.supertopic-platform { font-size: 10px; color: #f06292; margin-left: auto; }
.supertopic-content { font-size: 13px; color: #444; line-height: 1.6; }
.supertopic-meta { font-size: 10px; color: #f48fb1; margin-top: 6px; }

/* ═══ 朋友圈截图 — 聊天气泡 ═══ */
.media-wechat-moment { background: #1a1a1a; border-radius: 8px; padding: 12px; }
.wechat-user { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.wechat-avatar { width: 28px; height: 28px; border-radius: 4px; background: #4caf50; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.wechat-name { font-size: 12px; font-weight: 600; color: #7cb342; }
.wechat-text { font-size: 13px; color: #ddd; line-height: 1.6; background: #2a2a2a; padding: 8px 10px; border-radius: 8px; }
.wechat-meta { font-size: 10px; color: #666; margin-top: 6px; }
.wechat-warning { font-size: 10px; color: #ff9800; margin-top: 6px; padding: 4px 8px; background: rgba(255,152,0,0.1); border-radius: 4px; border: 1px solid rgba(255,152,0,0.2); }

/* ═══ 公众号文章 ═══ */
.media-wechat-article { background: #ffffff; border-radius: 8px; border: 1px solid #eee; }
.wechat-article-source { font-size: 11px; color: #888; margin-bottom: 6px; font-weight: 600; }
.wechat-article-title { font-size: 16px; font-weight: 700; color: #1a1a1a; margin-bottom: 8px; line-height: 1.3; }
.wechat-article-summary { font-size: 13px; color: #555; line-height: 1.6; }
.wechat-article-meta { font-size: 10px; color: #aaa; margin-top: 8px; padding-top: 6px; border-top: 1px solid #f5f5f5; }

/* ═══ 短视频 — 视频播放器 ═══ */
.media-shortvideo { background: #1a1a1a; border-radius: 10px; overflow: hidden; display: flex; gap: 0; }
.shortvideo-preview { width: 72px; min-height: 72px; background: linear-gradient(135deg, #1a1a2e, #16213e); display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0; }
.shortvideo-play { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; }
.shortvideo-duration { position: absolute; bottom: 4px; right: 4px; font-size: 9px; color: #fff; background: rgba(0,0,0,0.6); padding: 1px 4px; border-radius: 3px; }
.shortvideo-info { flex: 1; padding: 10px 12px; }
.shortvideo-author { font-size: 12px; font-weight: 600; color: #fff; margin-bottom: 4px; }
.shortvideo-platform { font-size: 10px; color: #ff5252; margin-left: 4px; }
.shortvideo-desc { font-size: 12px; color: #ccc; line-height: 1.5; }
.shortvideo-meta { font-size: 10px; color: #666; margin-top: 6px; }

/* ═══ 直播片段 ═══ */
.media-live { background: linear-gradient(135deg, #1a0a0a, #0a0a14); border: 1px solid #330000; border-radius: 8px; }
.live-badge { display: inline-block; font-size: 10px; padding: 2px 8px; background: #ff0000; color: #fff; border-radius: 3px; font-weight: 700; margin-bottom: 6px; animation: tv-blink 1.5s infinite; }
.live-platform { font-size: 12px; color: #ff6b6b; margin-bottom: 4px; font-weight: 600; }
.live-host { font-size: 11px; color: #aaa; margin-bottom: 6px; }
.live-content { font-size: 13px; color: #ddd; line-height: 1.6; }
.live-time { font-size: 10px; color: #555; margin-top: 6px; }

/* ═══ 小红书 — 生活方式卡片 ═══ */
.media-xhs { background: #ffffff; border-radius: 12px; border: 1px solid #ffe0e0; overflow: hidden; }
.xhs-user { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.xhs-avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #ff5252, #ff8a80); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.xhs-name { font-size: 12px; font-weight: 600; color: #333; }
.xhs-content { font-size: 13px; color: #444; line-height: 1.6; }
.xhs-tags { margin-top: 6px; }
.xhs-meta { font-size: 10px; color: #ff8a80; margin-top: 8px; padding-top: 6px; border-top: 1px solid #fff0f0; }

/* ═══ 八卦讨论 — 悬疑风格 ═══ */
.media-gossip { background: linear-gradient(135deg, #1a1520, #1e1a28); color: #d0c0e0; border: 1px solid #3a2f4a; border-left: 3px solid #ff9800; border-radius: 6px; }
.gossip-header { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.gossip-icon { font-size: 16px; }
.gossip-platform { font-size: 12px; font-weight: 600; color: #e0d0f0; }
.gossip-credibility { font-size: 10px; padding: 1px 6px; border-radius: 8px; font-weight: 600; }
.gossip-spreading { font-size: 10px; color: #ff6b6b; animation: tv-blink 1.5s infinite; }
.gossip-title { font-size: 14px; font-weight: 700; color: #ffd0a0; margin-bottom: 6px; }
.gossip-content { font-size: 13px; color: #b0a0c0; line-height: 1.6; }
.gossip-author { font-size: 10px; color: #6a5a7a; margin-top: 6px; }

/* ═══ 狗仔爆料 — 独家新闻 ═══ */
.media-paparazzi { background: #0a0a0a; color: #e0e0e0; border: 1px solid #333; border-top: 3px solid #ff4444; border-radius: 4px; }
.paparazzi-badge { display: inline-block; font-size: 10px; padding: 2px 8px; background: linear-gradient(135deg, #ff4444, #cc0000); color: #fff; border-radius: 3px; font-weight: 700; margin-bottom: 8px; letter-spacing: 1px; }
.paparazzi-source { font-size: 11px; color: #ff6b6b; margin-bottom: 6px; font-weight: 600; }
.paparazzi-title { font-size: 15px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.paparazzi-content { font-size: 13px; color: #bbb; line-height: 1.6; }
.paparazzi-meta { display: flex; justify-content: space-between; font-size: 10px; color: #666; margin-top: 8px; padding-top: 6px; border-top: 1px solid #222; }

/* ═══ 数据走势 — 仪表盘 ═══ */
.media-trend { background: linear-gradient(135deg, #0d1117, #161b22); color: #c9d1d9; border: 1px solid #30363d; border-radius: 8px; font-family: 'Consolas', 'Courier New', monospace; }
.trend-header { font-size: 12px; color: #58a6ff; margin-bottom: 8px; font-weight: 600; padding-bottom: 6px; border-bottom: 1px solid #30363d; }
.trend-title { font-size: 14px; color: #e6edf3; margin-bottom: 6px; font-weight: 600; }
.trend-content { font-size: 12px; color: #8b949e; line-height: 1.6; }
.trend-meta { font-size: 10px; color: #484f58; margin-top: 8px; }

/* ═══ 黑粉言论 — 暗黑风格 ═══ */
.media-hater { background: linear-gradient(135deg, #1a0a0a, #0f0505); color: #e0a0a0; border: 1px solid #3a1515; border-left: 3px solid #cc0000; border-radius: 6px; }
.hater-header { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.hater-icon { font-size: 14px; }
.hater-author { font-size: 12px; font-weight: 600; color: #ff6666; }
.hater-platform { font-size: 10px; color: #8a4444; margin-left: auto; }
.hater-content { font-size: 13px; color: #c08080; line-height: 1.6; background: rgba(204,0,0,0.05); padding: 6px 8px; border-radius: 4px; }
.hater-tags { margin-top: 6px; }
.hater-tag { display: inline-block; font-size: 10px; padding: 1px 6px; margin-right: 4px; border-radius: 3px; background: rgba(204,0,0,0.1); color: #ff6666; border: 1px solid rgba(204,0,0,0.2); }
.hater-meta { font-size: 10px; color: #6a3333; margin-top: 6px; }

/* ═══ 可信度标签 ═══ */
.cred-high { background: rgba(76,175,80,0.15); color: #4caf50; }
.cred-medium { background: rgba(255,152,0,0.15); color: #ff9800; }
.cred-low { background: rgba(244,67,54,0.15); color: #f44336; }

/* ═══ 通用兜底 ═══ */
.media-generic { background: rgba(255,255,255,0.05); color: #ccc; border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; }
.generic-type { font-size: 11px; color: #999; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.generic-content { font-size: 13px; color: #ddd; line-height: 1.6; }
.generic-meta { font-size: 10px; color: #666; margin-top: 6px; }

/* === 移动端适配 === */
@media (max-width: 768px) {
  .social-panel {
    width: 100%;
  }
  .social-panel-body {
    column-count: 1;
    padding: 12px;
  }
  .social-panel-header {
    padding: 12px 14px;
  }
  .social-header-left {
    gap: 8px;
  }
  .social-panel-header h3 {
    font-size: 14px;
  }
  .social-entry-meta {
    font-size: 11px;
    gap: 8px;
  }
}

/* =========================================
   Debug Panel — 调试面板
   ========================================= */

.debug-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  background: var(--bg-mid, #2d1a4a);
  z-index: 2000;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(200, 152, 240, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.debug-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.debug-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.debug-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(144, 96, 208, 0.15);
  border-bottom: 1px solid rgba(200, 152, 240, 0.2);
  flex-shrink: 0;
}

.debug-panel-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--dream-light, #c898f0);
  margin: 0;
}

.debug-panel-close {
  background: none;
  border: none;
  color: var(--dream-light, #c898f0);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.debug-panel-close:hover {
  background: rgba(200, 152, 240, 0.15);
}

.debug-panel-desc {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--pink-warm, #f48fb1);
  flex-shrink: 0;
  word-break: break-all;
}

.debug-panel-tabs {
  display: flex;
  gap: 4px;
  padding: 4px 16px;
  flex-shrink: 0;
}

.debug-tab {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(200, 152, 240, 0.15);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  color: rgba(200, 152, 240, 0.6);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.debug-tab.active {
  background: rgba(144, 96, 208, 0.25);
  color: var(--dream-light, #c898f0);
  border-color: rgba(200, 152, 240, 0.4);
}

.debug-content {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
  margin: 0;
  background: rgba(0, 0, 0, 0.3);
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #c8d8e8;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 200px;
}

.debug-panel-actions {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid rgba(200, 152, 240, 0.15);
  flex-shrink: 0;
}

.debug-panel-actions .settings-btn {
  flex: 1;
}

.archive-card-meta {
  font-size: 12px;
  color: rgba(200, 152, 240, 0.5);
}

.archive-card-stars {
  font-size: 11px;
  color: var(--pink-warm);
  margin-top: 2px;
}

.archive-card-actions {
  display: flex;
  gap: 6px;
  margin-left: 10px;
}

.archive-card-btn {
  background: rgba(144, 96, 208, 0.2);
  color: var(--dream-light);
  border: 1px solid rgba(200, 152, 240, 0.2);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.archive-card-btn:hover {
  background: rgba(144, 96, 208, 0.35);
}

.archive-card-btn-del {
  color: var(--pink-warm);
  border-color: rgba(244, 143, 177, 0.2);
  background: rgba(244, 143, 177, 0.08);
}

.archive-card-btn-del:hover {
  background: rgba(244, 143, 177, 0.2);
  border-color: rgba(244, 143, 177, 0.4);
}

/* ========== Token Info Bar ========== */
.msg-token-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 10px;
  background: rgba(144, 96, 208, 0.08);
  border-radius: 8px;
  border: 1px solid rgba(200, 152, 240, 0.12);
  font-size: 11px;
}

.token-tag {
  background: var(--dream-purple);
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

.token-detail {
  color: rgba(200, 152, 240, 0.6);
}

/* ========== Card Style Variants ========== */

/* Glass card */
body[data-card-style="glass"] .narrative-card {
  background: rgba(248, 244, 255, 0.15);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(200, 152, 240, 0.25);
  color: #e8ddf0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

body[data-card-style="glass"] .narrative-card p {
  color: #e8ddf0;
}

/* Minimal card */
body[data-card-style="minimal"] .narrative-card {
  background: transparent;
  border: none;
  border-left: 3px solid var(--dream-purple);
  border-radius: 0;
  padding: 12px 16px;
  box-shadow: none;
  color: #d8c8e8;
}

body[data-card-style="minimal"] .narrative-card p {
  color: #d8c8e8;
}

/* ========== Panel Backdrop (shared) ========== */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 190;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.panel-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* ========== Theme Selection Preview ========== */
.theme-select-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.theme-preview {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-preview:hover { transform: scale(1.1); }
.theme-preview.selected { border-color: #fff; box-shadow: 0 0 8px rgba(255,255,255,0.4); }

.theme-preview[data-val="purple"] { background: linear-gradient(135deg, #9060d0, #c898f0); }
.theme-preview[data-val="midnight"] { background: linear-gradient(135deg, #4080d0, #80b0f0); }
.theme-preview[data-val="rose"] { background: linear-gradient(135deg, #d04080, #f080b0); }
.theme-preview[data-val="forest"] { background: linear-gradient(135deg, #40a060, #80d0a0); }

/* =========================================
   Star Worldbook Panel — 女星世界书管理
   ========================================= */

.star-book-panel {
  position: fixed;
  top: 0;
  right: -440px;
  width: 420px;
  height: 100vh;
  background: var(--bg-mid, #2d1a4a);
  z-index: 1000;
  transition: right 0.3s ease;
  box-shadow: -4px 0 20px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.star-book-panel.open {
  right: 0;
}

.star-book-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.star-book-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(144, 96, 208, 0.15);
  border-bottom: 1px solid rgba(200, 152, 240, 0.2);
  flex-shrink: 0;
}

.star-book-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--dream-light, #c898f0);
  margin: 0;
}

.star-book-close {
  background: none;
  border: none;
  color: var(--dream-light, #c898f0);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.star-book-close:hover {
  background: rgba(200, 152, 240, 0.15);
}

.star-book-desc {
  padding: 8px 16px;
  font-size: 11px;
  color: rgba(200, 152, 240, 0.5);
  flex-shrink: 0;
}

.star-book-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.star-book-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--dream-light, #c898f0);
  padding: 8px 4px 4px;
  border-bottom: 1px solid rgba(200, 152, 240, 0.1);
  margin-bottom: 6px;
}

.star-book-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(200, 152, 240, 0.15);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.2s;
}

.star-book-card:hover {
  border-color: rgba(200, 152, 240, 0.3);
}

.star-book-card.star-custom {
  border-color: rgba(244, 143, 177, 0.2);
}

.star-book-card-info {
  flex: 1;
  min-width: 0;
}

.star-book-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--dream-light, #c898f0);
  display: block;
}

.star-book-card-kw {
  font-size: 10px;
  color: rgba(200, 152, 240, 0.4);
  display: block;
  margin-top: 2px;
}

.star-book-badge {
  display: inline-block;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(144, 96, 208, 0.2);
  color: var(--dream-light, #c898f0);
  margin-left: 4px;
}

.star-book-badge.avatar-badge {
  background: rgba(244, 143, 177, 0.15);
  color: var(--pink-warm, #f48fb1);
}

.star-book-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.star-book-empty {
  text-align: center;
  color: rgba(200, 152, 240, 0.3);
  padding: 40px 20px;
  font-size: 13px;
}

/* AI 一键生成世界书 */
.star-book-gen-section {
  padding: 12px 16px;
  border-top: 1px solid rgba(200, 152, 240, 0.15);
  background: rgba(26, 16, 48, 0.5);
}

.star-book-gen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.star-book-gen-header h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--dream-light, #c898f0);
}

.star-book-gen-arrow {
  transition: transform 0.2s;
  color: rgba(200, 152, 240, 0.5);
  font-size: 12px;
}

.star-book-gen-header.collapsed .star-book-gen-arrow {
  transform: rotate(-90deg);
}

.star-book-gen-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.star-book-gen-body.collapsed {
  display: none;
}

.star-gen-btn {
  background: var(--dream-light, #c898f0) !important;
  color: #1a1030 !important;
  font-weight: 600;
}

.star-gen-btn:hover:not(:disabled) {
  background: #d9b3f5 !important;
}

.star-gen-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.star-gen-hint {
  font-size: 12px;
  color: rgba(200, 152, 240, 0.7);
  margin-top: 4px;
  min-height: 16px;
}

.star-book-add-section {
  padding: 12px 16px;
  border-top: 1px solid rgba(200, 152, 240, 0.15);
  background: rgba(26, 16, 48, 0.5);
  flex-shrink: 0;
  max-height: 45vh;
  overflow-y: auto;
}

.star-book-add-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--dream-light, #c898f0);
  margin-bottom: 8px;
}

.star-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(200, 152, 240, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  color: #e8ddf0;
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.star-input:focus {
  outline: none;
  border-color: var(--dream-light, #c898f0);
}

.star-textarea {
  resize: vertical;
  min-height: 80px;
  max-height: 200px;
  line-height: 1.6;
}

.star-avatar-row {
  display: flex;
  gap: 8px;
}
.star-avatar-input {
  flex: 1;
}
.star-avatar-row .settings-btn {
  flex-shrink: 0;
  padding: 5px 14px;
}

.star-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.star-btn-row .settings-btn {
  flex: 1;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .star-book-panel {
    width: 100%;
    right: -100%;
  }
}

/* ========== 可编辑字段样式 ========== */
.info-row.editable,
.stat-bar.editable {
  cursor: pointer;
  transition: background 0.15s ease;
  border-radius: 4px;
  padding: 2px 4px;
  margin: 0 -4px;
}

.info-row.editable:hover,
.stat-bar.editable:hover {
  background: rgba(200, 152, 240, 0.12);
}

.info-row.editable:active,
.stat-bar.editable:active {
  background: rgba(200, 152, 240, 0.2);
}

/* 字段编辑器弹窗 */
.field-edit-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.15s ease;
}

.field-edit-dialog {
  background: var(--dream-bg, #1a1a2e);
  border: 1px solid rgba(200, 152, 240, 0.3);
  border-radius: 12px;
  padding: 20px;
  min-width: 300px;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.field-edit-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--dream-light, #c898f0);
  margin-bottom: 16px;
}

.field-edit-slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.field-edit-slider-wrap input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  outline: none;
}

.field-edit-slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--dream-accent, #9060d0);
  cursor: pointer;
  border: 2px solid #fff;
}

.field-edit-slider-wrap input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--dream-accent, #9060d0);
  cursor: pointer;
  border: 2px solid #fff;
}

.field-edit-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--dream-light, #c898f0);
  min-width: 50px;
  text-align: right;
}

.field-edit-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(200, 152, 240, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--dream-text, #e0d0f0);
  outline: none;
  margin-bottom: 16px;
  box-sizing: border-box;
}

.field-edit-input:focus {
  border-color: var(--dream-accent, #9060d0);
}

.field-edit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.field-edit-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.field-edit-btn.save {
  background: var(--dream-accent, #9060d0);
  color: #fff;
}

.field-edit-btn.cancel {
  background: rgba(255, 255, 255, 0.1);
  color: var(--dream-text, #e0d0f0);
}

.field-edit-btn:hover {
  opacity: 0.85;
}

/* ========== 校验告警弹窗 ========== */
.val-alert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  animation: fadeIn 0.2s ease;
}

.val-alert-dialog {
  background: var(--dream-bg, #1a1a2e);
  border: 1px solid rgba(200, 152, 240, 0.3);
  border-radius: 14px;
  width: 90%;
  max-width: 450px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.val-alert-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(200, 152, 240, 0.15);
}

.val-alert-icon {
  font-size: 20px;
}

.val-alert-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dream-light, #c898f0);
}

.val-alert-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.val-alert-desc {
  font-size: 13px;
  color: var(--dream-text-dim, #a090c0);
  margin-bottom: 12px;
}

.val-alert-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.val-group {
  border-radius: 8px;
  padding: 10px 12px;
}

.val-group.val-critical {
  background: rgba(232, 70, 58, 0.12);
  border-left: 3px solid #e8463a;
}

.val-group.val-error {
  background: rgba(239, 170, 23, 0.1);
  border-left: 3px solid #efaa17;
}

.val-group.val-warning {
  background: rgba(200, 152, 240, 0.08);
  border-left: 3px solid rgba(200, 152, 240, 0.5);
}

.val-group-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  color: var(--dream-text-dim, #a090c0);
}

.val-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
  font-size: 13px;
}

.val-field {
  font-family: monospace;
  font-size: 12px;
  color: var(--dream-text-dim, #a090c0);
}

.val-msg {
  color: var(--dream-text, #e0d0f0);
}

.val-alert-actions {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(200, 152, 240, 0.15);
  justify-content: flex-end;
}

.val-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.val-btn-repair {
  background: var(--dream-accent, #9060d0);
  color: #fff;
}

.val-btn-dismiss {
  background: rgba(255, 255, 255, 0.1);
  color: var(--dream-text, #e0d0f0);
}

.val-btn:hover {
  opacity: 0.85;
}

/* ========== Token Panel ========== */
.token-btn {
  font-size: 11px !important;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.token-btn:hover { opacity: 1; }

.token-panel {
  position: fixed;
  top: 0;
  right: -520px;
  width: 500px;
  max-width: 90vw;
  height: 100vh;
  background: var(--dream-bg2, #1a1528);
  z-index: 10001;
  transition: right 0.3s ease;
  overflow: hidden;
  box-shadow: -4px 0 30px rgba(0, 0, 0, 0.3);
}
.token-panel.open { right: 0; }

.token-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.token-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(200, 152, 240, 0.1);
  background: rgba(122, 106, 207, 0.08);
}
.token-panel-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--dream-text, #e0d0f0);
}

.token-panel-close {
  background: none;
  border: none;
  color: var(--dream-muted, #9a98aa);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}
.token-panel-close:hover {
  background: rgba(255, 255, 255, 0.08);
}

.token-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

/* Summary */
.token-summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.token-stat {
  text-align: center;
  padding: 10px 4px;
  background: rgba(122, 106, 207, 0.06);
  border-radius: 8px;
  border: 1px solid rgba(200, 152, 240, 0.08);
}
.token-stat-val {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--dream-purple, #9060d0);
}
.token-stat-label {
  display: block;
  font-size: 10px;
  color: var(--dream-muted, #9a98aa);
  margin-top: 2px;
}

/* Actions */
.token-actions {
  margin-bottom: 16px;
  text-align: right;
}

/* Empty */
.token-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--dream-muted, #9a98aa);
  font-size: 14px;
}
.token-empty-hint {
  display: block;
  font-size: 12px;
  margin-top: 8px;
  opacity: 0.6;
}

/* List */
.token-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.token-round-card {
  background: rgba(122, 106, 207, 0.04);
  border: 1px solid rgba(200, 152, 240, 0.08);
  border-radius: 10px;
  padding: 12px;
}

.token-round-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.token-round-num {
  font-weight: 600;
  font-size: 13px;
  color: var(--dream-text, #e0d0f0);
}
.token-round-time {
  font-size: 11px;
  color: var(--dream-muted, #9a98aa);
  flex: 1;
}
.token-round-total {
  font-size: 12px;
  font-weight: 600;
  color: var(--dream-purple, #9060d0);
}

.token-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.token-detail-table th {
  text-align: left;
  padding: 6px 8px;
  background: rgba(122, 106, 207, 0.08);
  color: var(--dream-muted, #9a98aa);
  font-weight: 500;
  font-size: 11px;
  border-radius: 4px;
}
.token-detail-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(200, 152, 240, 0.06);
  color: var(--dream-text, #e0d0f0);
}
.token-detail-table tr:last-child td {
  border-bottom: none;
}
.token-detail-table td:first-child {
  color: var(--dream-muted, #9a98aa);
}

/* Mobile */
@media (max-width: 600px) {
  .token-panel { width: 100vw; right: -100vw; }
  .token-summary { grid-template-columns: repeat(3, 1fr); }
  .token-stat:nth-child(4), .token-stat:nth-child(5) { grid-column: span 1; }
}

/* ========== 移动端适配修复 v2 ========== */

/* 动态视口高度，解决移动端浏览器地址栏遮挡问题 */
.app-layout,
.chat-section {
  height: 100vh;
  height: 100dvh;
}

/* 安全区域适配（刘海屏、底部横条） */
@supports (padding: env(safe-area-inset-top)) {
  .top-bar {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--top-bar-height) + env(safe-area-inset-top));
  }
  .input-area {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .mobile-panel-toggle,
  .mobile-left-toggle {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
  .settings-panel,
  .star-book-panel,
  .social-panel {
    padding-top: env(safe-area-inset-top);
  }
}

@media (max-width: 600px) {
  /* === 顶栏：防止按钮溢出 === */
  .top-bar {
    gap: 4px;
    padding: 0 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .top-bar::-webkit-scrollbar {
    display: none;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
    border-radius: 6px;
    flex-shrink: 0;
  }

  .scene-bar {
    min-width: 0;
    flex-shrink: 1;
    gap: 4px;
  }

  .scene-item {
    font-size: 10px;
    padding: 2px 6px;
  }

  /* === 输入区域：防止发送按钮被遮挡 === */
  .input-area {
    padding: 8px 10px;
  }

  .input-wrapper {
    gap: 6px;
  }

  #messageInput {
    padding: 8px 12px;
    font-size: 16px;
    min-height: 38px;
  }

  #sendBtn {
    padding: 8px 14px;
    font-size: 14px;
    flex-shrink: 0;
  }

  .input-meta {
    flex-wrap: wrap;
    gap: 4px;
  }

  .input-meta-left {
    gap: 4px;
  }

  /* 浮动按钮上移，避免遮挡输入区 */
  .mobile-panel-toggle,
  .mobile-left-toggle {
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }

  /* 面板全屏适配 */
  .settings-content,
  .star-book-inner {
    max-width: 100vw;
    width: 100vw;
  }
}

@media (max-width: 380px) {
  /* 超窄屏幕：进一步压缩 */
  .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .top-bar {
    gap: 3px;
    padding: 0 4px;
  }

  .scene-bar {
    max-width: 60px;
    overflow: hidden;
  }

  .scene-item {
    font-size: 9px;
    padding: 1px 4px;
  }

  #sendBtn {
    padding: 8px 10px;
    font-size: 13px;
  }

  .web-search-keyword {
    width: 100px;
  }
}


