/* ============================================================
 * 角色管理 + 设置集成 样式
 * ============================================================ */

/* --- 设置面板内状态显示 --- */
.cm-setting-status {
  margin-left: auto;
  font-size: 12px;
  color: #7ab8ff;
  margin-right: 12px;
}
.cm-setting-char {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 12px;
}
.cm-char-name-inline { font-size: 12px; color: #ccc; }

/* --- 通用按钮 --- */
.cm-btn {
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.cm-btn:hover { background: rgba(255,255,255,0.2); }
.cm-btn-small { padding: 4px 10px; font-size: 11px; }
.cm-btn-xsmall { padding: 3px 8px; font-size: 10px; }
.cm-btn-primary { background: #4a9eff; border-color: #4a9eff; }
.cm-btn-primary:hover { background: #3a8eef; }
.cm-btn-danger { background: rgba(255,80,80,0.2); border-color: rgba(255,80,80,0.4); }
.cm-btn-danger:hover { background: rgba(255,80,80,0.35); }
.cm-btn-block { display: block; width: 100%; margin-top: 12px; }
.cm-close {
  background: none; border: none; font-size: 22px; color: #aaa;
  padding: 0 6px; cursor: pointer; line-height: 1;
}
.cm-close:hover { color: #fff; }

/* --- 角色入口（设置面板内） --- */
/* 已合并到 .cm-setting-char */

/* --- 头像 --- */
.cm-avatar {
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
  overflow: hidden;
}

/* --- 角色管理面板 --- */
.cm-popup {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 9999; display: none; align-items: center; justify-content: center;
}
.cm-popup.cm-show { display: flex; }
.cm-panel-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
}
.cm-panel-container {
  position: relative; z-index: 1;
  width: 90%; max-width: 420px; max-height: 80vh;
  background: #1a1a2e; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.cm-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.cm-panel-title { font-size: 16px; font-weight: bold; color: #fff; }
.cm-panel-body { padding: 16px; overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }

/* --- 角色卡片列表 --- */
.cm-char-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.cm-char-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}
.cm-char-card.cm-char-current {
  border-color: #4a9eff;
  background: rgba(74,158,255,0.1);
}
.cm-char-card-mid { flex: 1; min-width: 0; }
.cm-char-card-name { font-size: 14px; font-weight: bold; color: #fff; }
.cm-char-card-gender { font-size: 11px; color: #999; margin-top: 2px; }
.cm-char-card-personality { font-size: 10px; color: #7ab8ff; margin-top: 3px; font-style: italic; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-char-card-right { display: flex; flex-direction: column; gap: 4px; }

/* --- 表单 --- */
.cm-form-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 10000; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7);
}
.cm-form-box {
  width: 90%; max-width: 380px; max-height: 85vh;
  background: #1a1a2e; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px; padding: 20px;
  overflow-y: auto; box-sizing: border-box; -webkit-overflow-scrolling: touch;
}
.cm-form-title { font-size: 16px; font-weight: bold; color: #fff; margin-bottom: 16px; }
.cm-form-row { margin-bottom: 14px; }
.cm-form-row label {
  display: block; font-size: 12px; color: #aaa; margin-bottom: 6px;
}
.cm-form-row input[type="text"], .cm-form-row select {
  width: 100%; padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 6px;
  background: rgba(0,0,0,0.3); color: #fff; font-size: 13px; outline: none;
  box-sizing: border-box;
}
.cm-form-avatar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cm-form-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  position: sticky; bottom: 0;
  background: #1a1a2e; padding: 12px 0 4px; margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* --- 游戏内角色切换悬浮按钮 --- */
.cm-game-char-btn {
  position: fixed; top: 12px; right: 12px; z-index: 9000;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,0.5); border: 2px solid rgba(255,255,255,0.25);
  cursor: grab; user-select: none; -webkit-user-select: none;
  touch-action: none;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s;
}
.cm-game-char-btn:active { cursor: grabbing; }
.cm-game-char-btn.dragging { opacity: 0.7; transform: scale(1.1); }
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.15s, border-color 0.15s;
  backdrop-filter: blur(4px);
}
.cm-game-char-avatar { display: flex; align-items: center; justify-content: center; }

/* --- 快速切换面板 --- */
.cm-quick-switch {
  position: fixed; top: 62px; right: 12px; z-index: 9001;
  width: 220px; max-height: 60vh; overflow-y: auto;
  background: rgba(20,20,35,0.95); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px; padding: 8px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.cm-quick-title { font-size: 11px; color: #888; padding: 4px 8px 8px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 4px; }
.cm-quick-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: #ddd;
}
.cm-quick-item:hover { background: rgba(255,255,255,0.08); }
.cm-quick-item.cm-quick-current { background: rgba(74,158,255,0.15); }
.cm-quick-item span { flex: 1; }
.cm-quick-badge {
  font-size: 10px; color: #4a9eff; background: rgba(74,158,255,0.15);
  padding: 2px 6px; border-radius: 4px; flex: none !important;
}
.cm-quick-manage { color: #888; font-size: 12px; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 4px; padding-top: 10px; }
/* --- 游戏原有设置面板滚动修复 --- */
#pop-setting, #pop-advsetting { max-height: 85vh !important; }
#pop-setting .container, #pop-advsetting .container,
#pop-setting > div:not([class]), #pop-advsetting > div:not([class]) {
  max-height: 70vh !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px !important;
}
/* 覆盖游戏内联样式，确保可滚动 */
#pop-setting [style*="overflow"], #pop-advsetting [style*="overflow"] {
  overflow-y: auto !important;
}
/* 收紧注入的设置行 */
#param-apikey, #param-characters {
  padding: 8px 16px !important;
  min-height: 40px !important;
}
#param-apikey .label, #param-characters .label {
  font-size: 14px !important;
}
.cm-setting-status {
  font-size: 12px;
  color: #4a9eff;
  margin-right: 8px;
  min-width: 50px;
  text-align: right;
}

.cm-auth-active{background:#4a90d9!important;color:#fff!important;border-color:#4a90d9!important}
