/* ═══════════════════════════════════════
   全域
   ═══════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  background: linear-gradient(135deg, #0a1628, #1a2744, #0f1f3a);
  min-height: 100vh;
  color: #e0e6f0;
}

/* ═══════════════════════════════════════
   登入畫面
   ═══════════════════════════════════════ */
#login-overlay {
  position: fixed; inset: 0; z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
}
/* 訪客模式：半透明遮罩讓市集角色可見 */
#login-overlay.guest-mode {
  background: rgba(15, 12, 41, 0.75);
  backdrop-filter: blur(6px);
}
#login-overlay .login-card {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px; padding: 48px 40px;
  width: 380px; max-width: 90vw;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
  text-align: center;
  animation: fadeIn 0.6s ease-out;
  position: relative;
}
/* 關閉按鈕 */
#login-overlay .login-close {
  position: absolute; top: 16px; right: 20px;
  font-size: 22px; color: rgba(255,255,255,0.4);
  cursor: pointer; line-height: 1;
  transition: color 0.2s;
  z-index: 10;
}
#login-overlay .login-close:hover { color: #fff; }
/* 📱 手機版登入畫面 */
@media (max-width: 480px) {
  #login-overlay .login-card {
    padding: 28px 20px;
    max-width: 92vw;
    border-radius: 18px;
  }
  #login-overlay .login-logo { font-size: 36px; margin-bottom: 4px; }
  #login-overlay .login-title { font-size: 22px; }
  #login-overlay .login-subtitle { font-size: 13px; margin-bottom: 20px; }
  #login-overlay .login-field { margin-bottom: 12px; }
  #login-overlay .login-field input { padding: 12px 16px; font-size: 15px; }
  #login-overlay .login-field label { font-size: 13px; }
  #login-overlay .login-btn { padding: 13px; font-size: 15px; }
  #login-overlay .login-error { font-size: 13px; }
  #login-overlay .login-toggle { font-size: 13px; margin-top: 12px; }
  /* 重設密碼卡片也跟著縮小 */
  #reset-password-card .login-logo { font-size: 36px; }
  #reset-password-card .login-title { font-size: 22px; }
  #reset-password-card .login-subtitle { font-size: 13px; margin-bottom: 20px; }
  /* 📱 底部導覽列：Android 強制放大 Emoji */
  .mobile-tab-bar {
    height: 60px !important;
    display: flex !important;
  }
  .mobile-tab-bar .tab-btn {
    font-size: 26px !important;
    padding: 4px 8px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
  }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
#login-overlay .login-logo { font-size: 56px; margin-bottom: 8px; }
#login-overlay .login-title { font-size: 26px; font-weight: 700; color: #fff; margin-bottom: 4px; }
#login-overlay .login-subtitle { font-size: 14px; color: rgba(255,255,255,0.5); margin-bottom: 32px; }
#login-overlay .login-field { margin-bottom: 16px; text-align: left; }
#login-overlay .login-field label { display: block; font-size: 13px; color: rgba(255,255,255,0.6); margin-bottom: 6px; padding-left: 4px; }
#login-overlay .login-field input {
  width: 100%; padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.15); border-radius: 12px;
  background: rgba(255,255,255,0.07); color: #fff; font-size: 15px; outline: none;
  transition: border 0.25s, box-shadow 0.25s;
}
#login-overlay .login-field input:focus { border-color: #4a8cd4; box-shadow: 0 0 0 3px rgba(74,140,212,0.25); }
#login-overlay .login-field input::placeholder { color: rgba(255,255,255,0.25); }
#login-overlay .login-btn {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #2a5f8a, #4a8cd4); color: #fff;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s; margin-top: 8px; letter-spacing: 1px;
}
#login-overlay .login-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(74,140,212,0.35); }
#login-overlay .login-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
#login-overlay .login-error { color: #f87171; font-size: 13px; margin-top: 12px; min-height: 20px; }
#login-overlay .login-toggle { margin-top: 16px; font-size: 13px; color: rgba(255,255,255,0.4); }
#login-overlay .login-toggle a { color: rgba(74,140,212,0.7); text-decoration: none; cursor: pointer; }
#login-overlay .login-toggle a:hover { color: #4a8cd4; }
#login-overlay .login-spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════
   全屏載入中遮罩（SoulForge 頭像生成 / 匯出）
   ═══════════════════════════════════════ */
.loading-overlay {
  position: fixed; inset: 0; z-index: 100000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(10, 8, 30, 0.85);
  backdrop-filter: blur(8px);
}
.loading-overlay .loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(168, 85, 247, 0.3);
  border-top-color: #a855f7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}
.loading-overlay .loading-text {
  color: rgba(255,255,255,0.8);
  font-size: 16px;
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  text-align: center;
  line-height: 1.6;
}

/* ═══════════════════════════════════════
   主畫面 — Lobby
   ═══════════════════════════════════════ */
.app-container { display: none; }
/* Email 強制綁定鎖死狀態：禁止所有互動 */
.app-container.bind-email-locked {
  pointer-events: none;
  user-select: none;
}
.app-header {
  padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
/* 📱 手機底部導覽列（手機版顯示） */
.mobile-tab-bar {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 99999; background: #0f1929;
  border-top: 1px solid rgba(255,255,255,0.08);
  height: 60px;
  padding-bottom: env(safe-area-inset-bottom);
  justify-content: space-around; align-items: center;
}
.mobile-tab-bar .tab-btn {
  background: none; border: none;
  color: rgba(255,255,255,0.5);
  font-size: 22px;  /* emoji 圖示尺寸 */
  padding: 0;
  cursor: pointer;
  transition: color 0.2s; text-align: center;
  line-height: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex: 1; height: 100%;
  gap: 2px;
}
.mobile-tab-bar .tab-btn .tab-label {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
}
.mobile-tab-bar .tab-btn.active { color: #4a8cd4; }
.mobile-tab-bar .tab-btn:active { color: #6aacf4; }
.app-header h1 { font-size: 20px; font-weight: 700; color: #fff; }
.app-header .user-badge {
  font-size: 13px; color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.1); padding: 6px 14px;
  border-radius: 20px; border: 1px solid rgba(255,255,255,0.15);
}
.app-header .tool-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.9);
  border-radius: 8px; cursor: pointer;
  transition: all 0.2s; white-space: nowrap;
}
.app-header .tool-btn:hover {
  background: rgba(74,140,212,0.2);
  border-color: rgba(74,140,212,0.35);
  color: #fff;
}
/* 右群組：帳號 + 工具（分隔線靠右） */
.header-right-group {
  display: flex; gap: 10px; align-items: center;
  margin-left: auto;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.12);
}
.app-content { padding: 24px; max-width: 1000px; margin: 0 auto; }

/* Bot 卡片列表 */
.bot-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px; margin-top: 16px;
}
.bot-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; padding: 20px;
  cursor: pointer; transition: all 0.25s ease;
  display: flex; align-items: center; gap: 14px;
}
.bot-card:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(74,140,212,0.4);
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.bot-card .bot-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, #2a5f8a, #4a8cd4);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff;
  box-shadow: 0 4px 12px rgba(74,140,212,0.3);
}
.bot-card .bot-avatar-img {
  width: 52px; height: 52px; border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(74,140,212,0.3);
}
.bot-card .bot-info { flex: 1; min-width: 0; }
.bot-card .bot-name { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.bot-card .bot-desc { font-size: 13px; color: rgba(255,255,255,0.45); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bot-card .bot-meta { font-size: 11px; color: rgba(255,255,255,0.3); margin-top: 6px; display: inline-block; background: rgba(255,255,255,0.06); padding: 2px 10px; border-radius: 10px; }

.create-bot-card {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 88px; border: 2px dashed rgba(255,255,255,0.12);
  border-radius: 16px; cursor: pointer; transition: all 0.25s;
  font-size: 15px; color: rgba(255,255,255,0.4);
}
.create-bot-card:hover {
  border-color: #4a8cd4; color: #4a8cd4;
  background: rgba(74,140,212,0.06);
  transform: translateY(-2px);
}

/* ═══════════════════════════════════════
   聊天畫面
   ═══════════════════════════════════════ */
.chat-view { display: none; height: 100dvh; max-height: 100dvh; flex-direction: column; overflow: hidden; box-sizing: border-box; }
/* 桌面版：聊天 + 角色面板左右並排 */
.chat-layout {
  display: flex; flex: 1; overflow: hidden;
}
.chat-main {
  display: flex; flex-direction: column; flex: 1; min-width: 0;
}
.chat-sidebar {
  display: none;
  width: 280px; flex-shrink: 0;
  background: rgba(10, 22, 40, 0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid rgba(255,255,255,0.12);
  padding: 24px 20px;
  overflow-y: auto;
}
@media (min-width: 900px) {
  .chat-sidebar { display: block; }
  .chat-sidebar.sidebar-collapsed { display: none; }
}
.drawer-close-btn {
  text-align: right;
  padding: 15px;
  color: #ff6b6b;
  font-size: 20px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.chat-sidebar .side-avatar {
  width: 120px; height: 120px; border-radius: 50%;
  object-fit: cover; margin: 0 auto 16px;
  display: block;
  box-shadow: 0 8px 30px rgba(74,140,212,0.3);
}
.chat-sidebar .side-avatar-placeholder {
  width: 120px; height: 120px; border-radius: 50%;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #2a5f8a, #4a8cd4);
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; font-weight: 700; color: #fff;
  box-shadow: 0 8px 30px rgba(74,140,212,0.3);
}
.chat-sidebar .side-name {
  text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 4px;
}
.chat-sidebar .side-mode {
  text-align: center; font-size: 12px; color: rgba(255,255,255,0.6); margin-bottom: 20px;
}
.chat-sidebar .side-section {
  margin-bottom: 16px;
}
.chat-sidebar .side-section h3 {
  font-size: 12px; color: rgba(255,255,255,0.65); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.chat-sidebar .side-section p {
  font-size: 13px; color: rgba(255,255,255,0.85); line-height: 1.6;
}
/* 好感度進度條 */
.side-affinity { margin-bottom: 16px; }
.side-relationship { font-size: 15px; color: #f0f4ff; margin-bottom: 6px; }
.affinity-bar { height: 4px; background: rgba(255,255,255,0.15); border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.affinity-fill { height: 100%; background: linear-gradient(90deg, #60a5fa, #a78bfa); border-radius: 2px; transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1); }
.affinity-label { font-size: 11px; color: rgba(255,255,255,0.8); }
/* 記憶面板 */
.side-memory { flex: 1; overflow-y: auto; min-height: 0; }
.side-memory h3 { display: flex; align-items: center; justify-content: space-between; }
.memory-item {
  font-size: 12px; color: rgba(255,255,255,0.85); line-height: 1.5;
  padding: 6px 8px; margin: 3px 0;
  background: rgba(255,255,255,0.08);
  border-radius: 6px; border-left: 2px solid rgba(168,85,247,0.5);
  display: flex; align-items: flex-start; gap: 6px;
  word-break: break-all;
}
.memory-item .memory-key { color: rgba(168,85,247,0.85); font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.memory-item .memory-val { flex: 1; }
.memory-item .memory-del {
  background: none; border: none; color: rgba(255,255,255,0.4); cursor: pointer;
  font-size: 14px; padding: 0 2px; flex-shrink: 0; line-height: 1;
}
.memory-item .memory-del:hover { color: #ef4444; }
.memory-star {
  cursor: pointer; font-size: 14px; flex-shrink: 0; line-height: 1.2;
  color: rgba(255,255,255,0.4); transition: color 0.2s; user-select: none;
}
.memory-star:hover { color: #fbbf24; }
.memory-star.pinned { color: #fbbf24; }
.memory-empty { font-size: 12px; color: rgba(255,255,255,0.4); text-align: center; padding: 12px 0; }
.chat-header {
  position: relative; z-index: 1;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(10, 22, 40, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-wrap: wrap;
}
.chat-header .back-btn {
  background: none; border: none; color: rgba(255,255,255,0.7);
  font-size: 22px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.chat-header .back-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.chat-header .chat-bot-name { font-size: 16px; font-weight: 600; flex: 1; color: #fff; }
.chat-header .tool-btn {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.9);
  border-radius: 8px; cursor: pointer;
  font-size: 11px; padding: 4px 8px;
  transition: all 0.2s; white-space: nowrap;
}
.chat-header .tool-btn:hover {
  background: rgba(74,140,212,0.2);
  border-color: rgba(74,140,212,0.35);
  color: #fff;
}
/* BGM 按鈕 */
.bgm-btn {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  color: #ccc; padding: 4px 10px; border-radius: 8px;
  font-size: 12px; cursor: pointer; transition: all 0.2s;
  white-space: nowrap; max-width: 140px; overflow: hidden;
  text-overflow: ellipsis;
}
.bgm-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* 情緒 emoji 動畫 */
.mood-emoji { display: inline-block; font-size: 16px; margin-left: 6px; animation: moodBounce 0.5s ease-out; }
@keyframes moodBounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}
/* 關係表情 emoji */
.rel-emoji { display: inline-block; font-size: 14px; margin-left: 4px; animation: relAppear 0.4s ease-out; }
@keyframes relAppear {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
/* 升級彩花粒子 */
.celebration-particle {
  position: absolute; top: -10px; pointer-events: none;
  animation: particleFall 1.2s ease-out forwards;
  z-index: 999;
}
@keyframes particleFall {
  0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(120px) rotate(360deg) scale(0.3); opacity: 0; }
}

.chat-header .chat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; border: 2px solid rgba(74,140,212,0.4);
  background: rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.chat-header .chat-avatar-placeholder {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #2a5f8a, #4a8cd4);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}

/* 功能按鈕列 */
.chat-toolbar {
  display: flex; gap: 4px; padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  flex-wrap: nowrap;
  overflow-x: auto;
  align-items: center;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chat-toolbar::-webkit-scrollbar { display: none; }
.chat-toolbar .tool-btn {
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.48);
  color: #fff;
  padding: 5px 10px; border-radius: 8px;
  font-size: 12px; cursor: pointer; transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.chat-toolbar .tool-btn:hover {
  background: rgba(74,140,212,0.15);
  border-color: rgba(74,140,212,0.3);
  color: #fff;
}
.chat-toolbar .tool-btn.active {
  background: rgba(74,140,212,0.2);
  border-color: #4a8cd4;
  color: #4a8cd4;
}
.chat-toolbar .tool-divider {
  width: 1px; height: 20px;
  background: rgba(255,255,255,0.08);
  margin: 0 2px;
}
.chat-toolbar .quota-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(251,191,36,0.25);
  color: #fcd34d;
  white-space: nowrap;
}
.chat-toolbar .quota-badge.quota-low {
  background: rgba(239,68,68,0.2);
  color: #ef4444;
}
.chat-toolbar .quota-badge.quota-premium {
  background: rgba(255,215,0,0.12);
  color: #ffd700;
  border: 1px solid rgba(255,215,0,0.2);
}
/* 「更多」下拉選單 */
.more-menu {
  position: relative; display: inline-block;
}
.more-menu .more-dropdown {
  display: block; position: fixed; z-index: 99999;
  background: #1a2744; border: 1px solid rgba(255,255,255,0.2);
  border-radius: 12px; padding: 6px; min-width: 160px; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  opacity: 0; pointer-events: none; transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.more-menu .more-dropdown.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.more-menu .more-dropdown .tool-btn {
  display: block; width: 100%; text-align: left;
  background: rgba(255,255,255,0.22); border: 1px solid rgba(255,255,255,0.15); padding: 8px 12px;
  border-radius: 8px; margin-bottom: 3px;
  color: rgba(255,255,255,0.9);
}
.more-menu .more-dropdown .tool-btn:last-child { margin-bottom: 0; }
.more-menu .more-dropdown .tool-btn:hover {
  background: rgba(74,140,212,0.2);
  color: #fff;
}

.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.chat-msg-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  max-width: 85%;
}
.chat-msg-wrap.user-wrap {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-msg-wrap.bot-wrap {
  align-self: flex-start;
}
.chat-msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, #2a5f8a, #4a8cd4);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
}
.chat-msg-avatar.user-avatar {
  background: linear-gradient(135deg, #1a3a5c, #2a5f8a);
}
.chat-msg {
  padding: 12px 16px; border-radius: 18px;
  font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  position: relative;
}
.chat-msg.user {
  background: linear-gradient(135deg, #1e4d7a, #3a7bb5);
  border-bottom-right-radius: 4px;
  color: #fff;
}
.chat-msg.bot {
  background: rgba(255,255,255,0.07);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.05);
}
.chat-msg .msg-time {
  font-size: 11px; color: rgba(255,255,255,0.3);
  margin-top: 4px; text-align: right;
}
.chat-msg.bot .msg-time { text-align: left; }

.chat-input-area {
  padding: 16px 24px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; gap: 12px;
  flex-shrink: 0;
  box-sizing: border-box;
}
.chat-input-area input {
  flex: 1; padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.15); border-radius: 12px;
  background: rgba(255,255,255,0.06); color: #fff; font-size: 14px; outline: none;
}
.chat-input-area button {
  padding: 12px 24px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #2a5f8a, #4a8cd4);
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform 0.15s;
}
.chat-input-area button:hover { transform: translateY(-1px); }
.chat-input-area button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.chat-input-area input:focus { border-color: #4a8cd4; }

.chat-img {
  max-width: 300px; width: 100%; display: block;
  border-radius: 12px; margin-top: 8px;
  cursor: pointer; transition: transform 0.2s;
}
.chat-img:hover { transform: scale(1.03); }

/* 設為頭像按鈕 */
.set-avatar-btn {
  display: inline-block; margin-top: 4px; padding: 4px 10px;
  font-size: 12px; background: rgba(74, 140, 212, 0.2);
  color: #8ab4f8; border: 1px solid rgba(74, 140, 212, 0.3);
  border-radius: 8px; cursor: pointer; transition: all 0.2s;
}
.set-avatar-btn:hover { background: rgba(74, 140, 212, 0.4); }
.set-avatar-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* 📱 手機版 gallery 頭像按鈕永遠顯示 */
@media (max-width: 768px) {
  .gallery-avatar-btn {
    opacity: 1 !important;
    display: inline-block !important;
  }
}

/* Lightbox */
.lightbox-overlay {
  display: none; position: fixed; inset: 0; z-index: 100000;
  background: rgba(0,0,0,0.85);
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox-overlay.show { display: flex; }
.lightbox-overlay img {
  max-width: 90vw; max-height: 90vh;
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* 畫廊 Modal */
.gallery-overlay {
  display: none; position: fixed; inset: 0; z-index: 100000;
  background: rgba(0,0,0,0.85);
  align-items: center; justify-content: center;
}
.gallery-overlay.show { display: flex; }
.gallery-card {
  background: #1e1b4b; border-radius: 20px; padding: 24px;
  width: 700px; max-width: 92vw; max-height: 85vh;
  border: 1px solid rgba(255,255,255,0.1);
  display: flex; flex-direction: column;
}
.gallery-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.gallery-header h2 { font-size: 18px; }
.gallery-header button {
  background: none; border: none; color: rgba(255,255,255,0.5);
  font-size: 22px; cursor: pointer; padding: 4px 8px;
}
.gallery-header button:hover { color: #fff; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; overflow-y: auto; flex: 1; padding: 4px;
}
.gallery-grid img {
  width: 100%; aspect-ratio: 9/16; object-fit: cover;
  border-radius: 10px; cursor: pointer;
  transition: transform 0.2s;
  border: 2px solid transparent;
}
.gallery-grid img:hover {
  transform: scale(1.05);
  border-color: rgba(74,140,212,0.5);
}

/* ═══════════════════════════════════════
   創建角色 Modal
   ═══════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 99998;
  background: rgba(0,0,0,0.6);
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-card {
  background: #1e1b4b; border-radius: 20px; padding: 32px;
  width: 480px; max-width: 90vw; max-height: 85vh; overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.1);
}
.modal-card h2 { font-size: 20px; margin-bottom: 20px; }
.modal-card .field { margin-bottom: 14px; }
.modal-card .field label { display: block; font-size: 13px; color: rgba(255,255,255,0.6); margin-bottom: 4px; }
.modal-card .field input,
.modal-card .field textarea,
.modal-card .field select {
  width: 100%; padding: 10px 14px; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px; background: rgba(255,255,255,0.06); color: #fff;
  font-size: 14px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.modal-card .field select option {
  background: #1e1b4b; color: #fff;
}
.modal-card .field textarea { min-height: 80px; resize: vertical; }
.modal-card .field input:focus,
.modal-card .field textarea:focus { border-color: #4a8cd4; }
.modal-btns { display: flex; gap: 12px; margin-top: 20px; }
.modal-btns button {
  flex: 1; padding: 10px; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.modal-btns .btn-primary { background: linear-gradient(135deg, #2a5f8a, #4a8cd4); color: #fff; }
.modal-btns .btn-secondary { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.6); }

/* 滾動條美化 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
/* ═══════════════════════════════════════
   RWD
   ═══════════════════════════════════════ */
@media (max-width: 600px) {
  .app-content { padding: 16px; }
  .bot-grid { grid-template-columns: 1fr; gap: 12px; }
  /* 📱 手機版角色卡片字體縮小 */
  .bot-card .bot-name { font-size: 14px; }
  .bot-card .bot-desc { font-size: 12px; }
  .bot-card .bot-meta { font-size: 10px; }
  .bot-card .bot-avatar-img { width: 56px; height: 56px; min-width: 56px; }
  .bot-card { padding: 12px; gap: 10px; }
  .create-bot-card { min-height: 100px; }
  .create-bot-card .create-icon { font-size: 28px; }
  .create-bot-card .create-text { font-size: 12px; }
  /* 📱 手機版底部導覽按鈕 — emoji 用 font-size 控制尺寸 */
  .chat-messages { padding: 14px 12px; }
  .chat-msg-wrap { max-width: 92%; }
  .chat-input-area { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); gap: 8px; flex-shrink: 0; box-sizing: border-box; }
  .chat-input-area input { padding: 10px 12px; font-size: 13px; }
  .chat-input-area button { padding: 10px 16px; font-size: 13px; }
  .chat-header { padding: 10px 12px; }
  .chat-toolbar { padding: 6px 8px; gap: 3px; }
  .chat-toolbar .tool-btn { padding: 4px 8px; font-size: 11px; background: rgba(255,255,255,0.48); border-color: rgba(255,255,255,0.52); color: #fff; }
  .login-card { padding: 32px 24px; }
  .chat-sidebar { display: none !important; }
    /* 📱 手機版 header：按鈕折行 + 滾動 */
  .app-header {
    flex-wrap: wrap; gap: 4px; padding: 10px 12px;
  }
  .app-header h1 {
    font-size: 15px; width: 100%; margin-bottom: 2px;
  }
  .app-header > div {
    flex-wrap: nowrap; gap: 3px; justify-content: flex-start;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    width: 100%; padding-bottom: 2px;
  }
  .app-header .tool-btn {
    font-size: 10px !important; padding: 3px 6px !important;
    flex-shrink: 0;
  }
  .header-right-group {
    margin-left: 0; padding-left: 8px;
  }
  .app-header .user-badge {
    font-size: 10px; padding: 3px 8px; flex-shrink: 0;
  }
  .app-header .credits-badge {
    font-size: 10px; flex-shrink: 0;
  }
  /* 📱 手機版市集 toolbar 折行 + 滿版 */
  .mp-toolbar {
    gap: 4px !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .mp-toolbar .tool-row {
    display: flex !important;
    gap: 4px !important;
    flex-wrap: wrap !important;
    align-items: center !important;
  }
}

/* 📱 極小螢幕手機 (<400px) */
@media (max-width: 400px) {
  .app-content { padding: 10px; }
  .bot-card .bot-name { font-size: 13px; }
  .bot-card .bot-desc { font-size: 11px; }
  .bot-card .bot-avatar-img { width: 44px; height: 44px; min-width: 44px; }
  .bot-card { padding: 8px; gap: 8px; }
  .app-header h1 { font-size: 13px; }
  .app-header .tool-btn { font-size: 9px !important; padding: 2px 5px !important; }
  .app-header .user-badge { font-size: 9px; padding: 2px 6px; }
  .app-header .credits-badge { font-size: 9px; }
  #login-overlay .login-card { padding: 20px 16px; max-width: 96vw; }
  #login-overlay .login-title { font-size: 19px; }
  #login-overlay .login-field input { padding: 10px 12px; font-size: 14px; }
  #login-overlay .login-btn { padding: 11px; font-size: 14px; }
}
/* 📱 手機版專用樣式 (≤768px) */
@media (max-width: 768px) {
  /* 手機版好感度顯示在 header 下方 */
  .mobile-affinity-bar {
    display: flex !important;
    padding: 6px 14px;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
  }
  .mobile-affinity-bar .mob-rel {
    font-size: 12px; color: #8ab4f8; white-space: nowrap;
  }
  .mobile-affinity-bar .mob-bar-wrap {
    flex: 1; height: 3px; background: rgba(255,255,255,0.1);
    border-radius: 2px; overflow: hidden;
  }
  .mobile-affinity-bar .mob-bar-fill {
    height: 100%; background: linear-gradient(90deg, #60a5fa, #a78bfa);
    border-radius: 2px; transition: width 0.5s ease;
  }
  .mobile-affinity-bar .mob-label {
    font-size: 11px; color: rgba(255,255,255,0.35); white-space: nowrap;
  }
  /* 📱 手機底部導覽列 */
  .mobile-tab-bar { display: flex; }
  /* 避開底部導覽列 */
  .app-container { padding-bottom: 52px; }
  /* 📱 手機版 header 精簡：保留語系/登出等必要功能 */
  .app-header {
    display: flex !important;
    padding: 8px 12px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .app-header h1 { display: none; }
  .app-header .user-badge { display: none; }
  .app-header #marketplace-btn { display: none; }
  .app-header #studio-btn { display: none; }
  .app-header #buy-credits-btn { font-size: 10px; padding: 3px 6px; }
  .app-header #lang-switch-btn { font-size: 10px; padding: 3px 6px; }
  .app-header #logout-btn { font-size: 10px; padding: 3px 6px; }
  .app-header .credits-badge { font-size: 10px; padding: 2px 8px; }
  /* 📱 手機 Modal 滿版 */
  .modal-card, .marketplace-card, .gallery-card, .login-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 24px 16px !important;
    height: 100vh !important;
  }
  /* 📖 說明 Modal RWD：保留圓角與內距，不套滿版 */
  #help-modal .modal-card {
    width: 96vw !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    border-radius: 16px !important;
    margin: auto !important;
    padding: 0 !important;
    height: auto !important;
  }
  /* 說明內的 2 欄網格 → 手機單欄 */
  #help-modal .help-grid-2col {
    grid-template-columns: 1fr !important;
  }
  /* 📱 聊天輸入框手機鍵盤修正 */
  .chat-input-area.chat-input-keyboard {
    position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 9999;
    border-top: 1px solid rgba(255,255,255,0.12);
    background: #0f1929;
  }
  .chat-messages.chat-messages-keyboard {
    padding-bottom: 70px;
  }
  /* 📱 手機版聊天室：高度鎖定 + 輸入框防遮 */
  #chat-view {
    height: 100vh !important;
    height: -webkit-fill-available !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }
  .chat-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .chat-input-area {
    position: relative !important;
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 12px)) !important;
    z-index: 10;
    flex-shrink: 0;
  }
  .mobile-tab-bar {
    position: fixed !important;
    bottom: 0 !important;
    z-index: 999 !important;
  }
  /* 📱 手機版側邊欄 → 右側滑出抽屜 */
  .chat-sidebar {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    right: -100vw !important;
    width: 85vw !important;
    height: calc(100vh - 58px) !important;
    z-index: 9999 !important;
    background: rgba(10, 22, 40, 0.95) !important;
    backdrop-filter: blur(25px) !important;
    -webkit-backdrop-filter: blur(25px) !important;
    transition: right 0.3s ease-in-out !important;
    box-shadow: -5px 0 25px rgba(0,0,0,0.5);
    overflow-y: auto;
  }
  .chat-sidebar.drawer-open {
    right: 0 !important;
  }
  .drawer-close-btn {
    display: block !important;
    text-align: right;
    padding: 15px;
    color: #ff6b6b;
    font-size: 20px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
}

/* ═══════════════════════════════════════
   角色市集 Modal
   ═══════════════════════════════════════ */
.marketplace-overlay {
  display: none; position: fixed; inset: 0; z-index: 99998;
  background: rgba(0,0,0,0.7);
  align-items: center; justify-content: center;
}
.marketplace-overlay.show { display: flex; }
.marketplace-card {
  background: #1a2744; border-radius: 20px;
  width: 780px; max-width: 92vw; max-height: 88vh;
  border: 1px solid rgba(255,255,255,0.1);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
}
.marketplace-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.marketplace-header h2 { font-size: 20px; }
.marketplace-close {
  background: none; border: none; color: rgba(255,255,255,0.4);
  font-size: 22px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
  transition: all 0.2s;
}
.marketplace-close:hover { background: rgba(255,255,255,0.08); color: #fff; }
.marketplace-search-area {
  display: flex; gap: 8px; padding: 12px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.marketplace-search-area input {
  flex: 1; padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.15); border-radius: 10px;
  background: rgba(255,255,255,0.06); color: #fff; font-size: 14px; outline: none;
  transition: border 0.25s;
}
.marketplace-search-area input:focus { border-color: #4a8cd4; }
.marketplace-search-area input::placeholder { color: rgba(255,255,255,0.3); }
.marketplace-search-area select,
#mp-category-select, #mp-sort-select {
  color: #e0e0e0; background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
}
.marketplace-search-area select option,
#mp-category-select option, #mp-sort-select option {
  background: #1a2744; color: #e0e0e0;
}
.marketplace-search-btn {
  padding: 10px 18px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, #2a5f8a, #4a8cd4);
  color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: transform 0.15s;
}
.marketplace-search-btn:hover { transform: translateY(-1px); }
.marketplace-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; padding: 16px 24px; overflow-y: auto; flex: 1;
}
.marketplace-item {
  position: relative;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px; padding: 16px;
  transition: all 0.25s ease;
  display: flex; flex-direction: column; gap: 8px;
}
.marketplace-item:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(74,140,212,0.3);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.marketplace-item .mp-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, #2a5f8a, #4a8cd4);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff;
  margin: 0 auto;
}
.marketplace-item .mp-avatar-img {
  width: 48px; height: 48px; border-radius: 50%;
  object-fit: cover; margin: 0 auto;
}
.marketplace-item .mp-name {
  font-size: 15px; font-weight: 600; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.marketplace-item .mp-desc {
  font-size: 12px; color: rgba(255,255,255,0.45); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 3em;
}
.marketplace-item .mp-meta {
  font-size: 11px; color: rgba(255,255,255,0.35);
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
.marketplace-item .mp-meta .mp-by { color: rgba(74,140,212,0.6); }
.marketplace-item .mp-download-count { margin-left: auto; }
.marketplace-item .mp-price-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  z-index: 2;
}
.marketplace-item .mp-price-badge.free {
  background: rgba(74,222,128,0.15);
  color: #4ade80;
}
.marketplace-item .mp-price-badge.premium {
  background: rgba(255,215,0,0.15);
  color: #ffd700;
}
.marketplace-item .mp-price-value {
  font-size: 13px;
  font-weight: 700;
  color: #ffd700;
  text-align: center;
}
.marketplace-item .mp-download-btn {
  width: 100%; padding: 8px; border: none; border-radius: 8px;
  background: linear-gradient(135deg, #2a5f8a, #4a8cd4);
  color: #fff; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; margin-top: auto;
}
.marketplace-item .mp-download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74,140,212,0.3);
}
.marketplace-footer {
  display: flex; justify-content: center; align-items: center;
  gap: 16px; padding: 12px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.marketplace-footer .mp-page-btn {
  padding: 6px 14px; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.6); font-size: 13px; cursor: pointer;
  transition: all 0.2s;
}
.marketplace-footer .mp-page-btn:hover {
  background: rgba(74,140,212,0.15);
  border-color: rgba(74,140,212,0.3);
  color: #fff;
}
.marketplace-footer .mp-page-btn:disabled {
  opacity: 0.3; cursor: not-allowed;
}
.marketplace-footer .mp-page-info {
  font-size: 13px; color: rgba(255,255,255,0.4);
}
.marketplace-empty {
  text-align: center; padding: 60px 20px;
  color: rgba(255,255,255,0.3); font-size: 14px;
  grid-column: 1 / -1;
}

/* Bot card 上的公開/取消公開按鈕 */
.bot-public-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; padding: 4px 8px;
  font-size: 12px; cursor: pointer;
  color: rgba(255,255,255,0.7);
  transition: all 0.2s;
  opacity: 0; line-height: 1.4;
  z-index: 10;
}
.bot-card { position: relative; }
.bot-card:hover .bot-public-btn { opacity: 1; }
.bot-public-btn:hover {
  background: rgba(74,140,212,0.3);
  border-color: rgba(74,140,212,0.5);
  color: #fff;
}

/* 📱 手機版永遠顯示公開/刪除按鈕 */
@media (max-width: 768px) {
  .bot-public-btn, .bot-delete-btn { opacity: 1 !important; z-index: 999 !important; }
  .bot-card .bot-public-btn, .bot-card .bot-delete-btn { opacity: 1 !important; z-index: 999 !important; }
  .bot-card { overflow: visible !important; }
  /* 避免 avatar 蓋住按鈕 */
  .bot-card .bot-avatar, .bot-card .bot-avatar-img { z-index: 0; position: relative; }
}
.bot-delete-btn {
  position: absolute; top: 8px; right: 40px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; padding: 4px 8px;
  font-size: 12px; cursor: pointer;
  color: rgba(255,100,100,0.7);
  transition: all 0.2s;
  opacity: 0; line-height: 1.4;
  z-index: 10;
}
.bot-card:hover .bot-delete-btn { opacity: 1; }
.bot-delete-btn:hover {
  background: rgba(220,50,50,0.3);
  border-color: rgba(220,50,50,0.5);
  color: #ff6b6b;
}

@media (max-width: 600px) {
/* ═══════════════════════════════════════════
   ⚙️ 管理員後台
   ═══════════════════════════════════════════ */
.admin-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.admin-content {
  background: linear-gradient(135deg, #1a1a2e, #302b63);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  width: 100%;
  max-width: 1000px;
  margin-top: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.admin-header h2 { margin: 0; font-size: 18px; }
.admin-close {
  background: none; border: none; color: #aaa; font-size: 22px;
  cursor: pointer; padding: 4px 10px; border-radius: 8px;
}
.admin-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.admin-body { padding: 16px 20px 20px; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #888;
  font-weight: 600;
  white-space: nowrap;
}
.admin-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.admin-table tr:hover td { background: rgba(255,255,255,0.03); }
.admin-premium-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f7971e, #ffd200);
  color: #1a1a2e;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.admin-quota-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #ddd;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 11px;
  cursor: pointer;
  margin: 2px;
  transition: all 0.2s;
}
.admin-quota-btn:hover { background: rgba(255,255,255,0.15); }
.admin-quota-btn.premium-on { background: rgba(255,215,0,0.2); border-color: #ffd700; color: #ffd700; }
.admin-quota-btn.premium-off { background: rgba(255,80,80,0.15); border-color: rgba(255,80,80,0.3); color: #ff6b6b; }
.admin-small { color: #666; font-size: 11px; }
.admin-refresh-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #aaa;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 12px;
}
.admin-refresh-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.admin-user-id { font-family: monospace; font-size: 11px; color: #888; }
.admin-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 10px 24px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 99999;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  animation: fadeInUp 0.3s ease;
}

/* Admin Page Tabs */
.admin-tabs {
  display: flex;
  gap: 0;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.admin-tab {
  background: none;
  border: none;
  color: #888;
  padding: 10px 20px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.admin-tab:hover { color: #ddd; }
.admin-tab.active {
  color: #fff;
  border-bottom-color: #ffd700;
}

/* Payment Status Badges */
.payment-status-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.payment-status-badge.completed { background: rgba(74,222,128,0.15); color: #4ade80; }
.payment-status-badge.pending  { background: rgba(250,204,21,0.15); color: #facc15; }
.payment-status-badge.failed   { background: rgba(255,80,80,0.15); color: #ff6b6b; }
.payment-status-badge.refunded { background: rgba(147,51,234,0.15); color: #a855f7; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ═══════════════════════════════════════
   🪙 Pricing & Credits UI（P1-2 金流）
   規格：Aria v1.1 + Rex AUDIT [RESOLVED]
   ═══════════════════════════════════════ */

/* Credits Badge — Header */
.credits-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,215,0,0.12);
  border: 1px solid rgba(255,215,0,0.25);
  color: #ffd700;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.credits-badge:hover {
  background: rgba(255,215,0,0.2);
  border-color: rgba(255,215,0,0.4);
  transform: translateY(-1px);
}

/* Pricing Modal */
.pricing-card {
  width: 520px;
  max-width: 92vw;
}
.pricing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.pricing-header h2 {
  margin: 0;
}
.pricing-balance {
  font-size: 14px;
  color: #ffd700;
  font-weight: 600;
}
.pricing-desc {
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  margin-bottom: 24px;
}
.pricing-plans {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

/* 雙軌制分頁切換 */
.pricing-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 4px;
}
.pricing-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.pricing-tab.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.pricing-tab:hover:not(.active) {
  color: rgba(255,255,255,0.6);
}

.pricing-plan-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.pricing-plan {
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.25s;
  position: relative;
}
.pricing-plan:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,215,0,0.2);
}
.pricing-plan.recommended {
  border-color: rgba(255,215,0,0.4);
  background: rgba(255,215,0,0.06);
}
.pricing-plan.current-plan {
  border-color: rgba(74,222,128,0.4);
  background: rgba(74,222,128,0.04);
}
.pricing-plan-header {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.pricing-plan-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.pricing-plan-name {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}
.pricing-plan-rec {
  font-size: 10px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
}
.pricing-plan-price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.pricing-plan-price {
  font-size: 28px;
  font-weight: 800;
  color: #ffd700;
}
.pricing-plan-period {
  font-size: 14px;
  color: rgba(255,255,255,0.4);
}
.pricing-plan-discount {
  font-size: 11px;
  background: rgba(74,222,128,0.2);
  color: #4ade80;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  margin-left: 4px;
}
.pricing-plan-body {
  flex: 1;
  margin-bottom: 14px;
}
.pricing-plan-perks {
  list-style: none;
  padding: 0;
  margin: 0 0 12px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pricing-plan-perks li {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  padding-left: 4px;
}
.pricing-plan-worlds {
  margin-top: 8px;
}
.pricing-plan-worlds-label {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  display: block;
  margin-bottom: 6px;
}
.pricing-plan-world-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.pricing-plan-world-tag {
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.6);
  padding: 3px 8px;
  border-radius: 6px;
}
.pricing-plan-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pricing-plan-btn {
  width: 100%;
  background: linear-gradient(135deg, #2a5f8a, #4a8cd4);
  border: none;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.pricing-plan-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(74,140,212,0.3);
}
.pricing-plan-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.pricing-plan-btn.current {
  background: rgba(74,222,128,0.15);
  color: #4ade80;
  cursor: default;
  border: 1px solid rgba(74,222,128,0.2);
}
.pricing-plan-annual-note {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  text-align: center;
}

/* Polling State */
.pricing-polling {
  text-align: center;
  padding: 24px 0;
}
.pricing-polling p {
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  margin: 8px 0;
}
.pricing-polling-hint {
  font-size: 12px !important;
  color: rgba(255,255,255,0.3) !important;
}
.pricing-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: #ffd700;
  border-radius: 50%;
  animation: pricingSpin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes pricingSpin {
  to { transform: rotate(360deg); }
}

/* Error State */
.pricing-error {
  color: #f87171;
  font-size: 13px;
  text-align: center;
  min-height: 20px;
  padding: 8px 0;
}

/* Transaction List */
.tx-list {
  max-height: 360px;
  overflow-y: auto;
  margin: 12px 0;
}
.tx-empty {
  text-align: center;
  padding: 32px 0;
  color: rgba(255,255,255,0.3);
  font-size: 14px;
}
.tx-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.tx-item:last-child {
  border-bottom: none;
}
.tx-item-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  word-break: break-word;
  max-width: 240px;
}
.tx-item-time {
  font-size: 11px;
  color: rgba(255,255,255,0.2);
  margin-top: 2px;
}
.tx-item-amount {
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}
.tx-item-amount.positive {
  color: #4ade80;
}
.tx-item-amount.negative {
  color: #f87171;
}

/* ═══════════════════════════════════════
   🔥 SoulForge 靈魂熔爐（Phase 2）
   ═══════════════════════════════════════ */

/* 主容器 */
#soulforge-view {
  display: none;
  height: 100vh;
  flex-direction: column;
  background: #0f1929;
}

/* 頂部導覽列 */
.sf-header {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  gap: 12px;
  flex-shrink: 0;
}
.sf-header .back-btn {
  background: none; border: none; color: rgba(255,255,255,0.5);
  font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
  white-space: nowrap;
}
.sf-header .back-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
/* 通用 back-btn（工作室、聊天室等 view 共用） */
.back-btn {
  background: none; border: none; color: rgba(255,255,255,0.45);
  font-size: 15px; cursor: pointer; padding: 4px 10px; border-radius: 8px;
  white-space: nowrap; transition: all 0.15s;
}
.back-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sf-title {
  flex: 1; display: flex; align-items: center; gap: 8px;
}
.sf-title .sf-logo { font-size: 22px; }
.sf-title span:last-child { font-size: 17px; font-weight: 700; }
.sf-actions {
  display: flex; align-items: center; gap: 8px;
}
.sf-cost-badge {
  font-size: 11px; padding: 3px 10px;
  border-radius: 10px;
  background: rgba(251,191,36,0.15);
  color: #fbbf24;
  white-space: nowrap;
}

/* 雙區塊體 */
.sf-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 左側對話區塊 */
.sf-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.sf-chat-header {
  padding: 10px 20px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sf-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sf-msg {
  max-width: 85%;
  display: flex;
}
.sf-msg.user { align-self: flex-end; }
.sf-msg.bot { align-self: flex-start; }
.sf-msg-content {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.sf-msg.user .sf-msg-content {
  background: linear-gradient(135deg, #1e4d7a, #3a7bb5);
  border-bottom-right-radius: 4px;
  color: #fff;
}
.sf-msg.bot .sf-msg-content {
  background: rgba(168,85,247,0.12);
  border: 1px solid rgba(168,85,247,0.15);
  border-bottom-left-radius: 4px;
  color: #d0d8e0;
}
/* 打字機效果：閃爍游標 */
.sf-msg.bot .sf-msg-content.typing::after {
  content: '|';
  animation: sfBlink 0.7s infinite;
  color: rgba(168,85,247,0.6);
}
@keyframes sfBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.sf-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.sf-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 14px;
  outline: none;
}
.sf-input-row input:focus { border-color: rgba(168,85,247,0.5); }
.sf-input-row input::placeholder { color: rgba(255,255,255,0.25); }
.sf-input-row textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}
.sf-input-row textarea:focus { border-color: rgba(168,85,247,0.5); }
.sf-input-row textarea::placeholder { color: rgba(255,255,255,0.25); }
.sf-input-row button {
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s;
}
.sf-input-row button:hover { transform: translateY(-1px); }
.sf-input-row button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* 右側卡片預覽區塊 */
.sf-preview {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sf-preview-header {
  padding: 10px 16px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* 🤖 AI 狀態指示器 */
.sf-status-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
  transition: all 0.3s;
}
.sf-status-badge.waiting {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.4);
}
.sf-status-badge.generating {
  background: rgba(168,85,247,0.15);
  color: #c084fc;
  animation: sfPulse 1.5s ease-in-out infinite;
}
@keyframes sfPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.sf-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 🎯 ST V2 驗證徽章 */
.sf-val-badge {
  font-size: 10px;
  margin-left: 4px;
}
.sf-val-badge.valid { color: #4ade80; }
.sf-val-badge.invalid { color: #fbbf24; }

/* 🎯 提示詞模板欄 */
.sf-prompt-bar {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  overflow-x: auto;
  flex-shrink: 0;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sf-prompt-chip {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}
.sf-prompt-chip:hover {
  background: rgba(168,85,247,0.2);
  border-color: rgba(168,85,247,0.4);
  color: #d8b4fe;
}
.sf-prompt-label {
  flex-shrink: 0;
}

/* 頭像預覽區 */
.sf-avatar-preview {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 8px 16px;
}
.sf-avatar-preview img {
  width: 180px;
  height: 240px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid rgba(251,191,36,0.3);
  box-shadow: 0 4px 20px rgba(251,191,36,0.15);
}
/* 大頭照 1:1 模式 */
.sf-avatar-preview.headshot img {
  width: 200px;
  height: 200px;
  border-color: rgba(56,189,248,0.4);
  box-shadow: 0 4px 20px rgba(56,189,248,0.2);
}
/* 🔥 AI 寫入時欄位發光動畫 */
@keyframes ai-update-glow {
  0%   { box-shadow: 0 0 0 rgba(168,85,247,0); border-color: rgba(255,255,255,0.1); }
  50%  { box-shadow: 0 0 12px rgba(168,85,247,0.5); border-color: #a855f7; }
  100% { box-shadow: 0 0 0 rgba(168,85,247,0); border-color: rgba(255,255,255,0.1); }
}
.sf-field-input.ai-updating,
.sf-ta.ai-updating {
  animation: ai-update-glow 1.5s ease-out;
}
/* 🔒 鎖定狀態的輸入框：降低視覺權重 */
.sf-field-input[readonly],
.sf-ta[readonly] {
  background: rgba(0,0,0,0.3);
  color: #718096;
  border-color: rgba(255,255,255,0.05);
  cursor: not-allowed;
  opacity: 0.7;
}
.sf-field {}
.sf-field-label {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sf-field-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.sf-field-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: #d0d8e0;
  font-size: 13px;
  outline: none;
  min-width: 0;
}
.sf-field-input:focus {
  border-color: rgba(168,85,247,0.5);
  background: rgba(168,85,247,0.06);
}
.sf-field-input:not(:read-only):not([readonly]) {
  border-color: rgba(168,85,247,0.3);
  background: rgba(168,85,247,0.06);
}
.sf-ta {
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
}
/* 鎖頭按鈕 */
.sf-lock-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  line-height: 1;
}
.sf-lock-btn.locked {
  border-color: rgba(74,222,128,0.3);
  background: rgba(74,222,128,0.1);
  color: #4ade80;
}
.sf-lock-btn.unlocked {
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.4);
}
.sf-lock-btn:hover {
  transform: scale(1.1);
}
.sf-lock-btn.locked:hover {
  border-color: rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.1);
  color: #ef4444;
}
.sf-lock-btn.unlocked:hover {
  border-color: rgba(74,222,128,0.4);
  background: rgba(74,222,128,0.1);
  color: #4ade80;
}

/* 批量鎖定按鈕列 */
.sf-batch-lock {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sf-batch-btn {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.5);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-align: center;
}
.sf-batch-btn:hover {
  background: rgba(168,85,247,0.1);
  border-color: rgba(168,85,247,0.3);
  color: #c084fc;
}

/* 手機版 RWD */
@media (max-width: 768px) {
  .sf-body {
    flex-direction: column;
  }
  .sf-chat {
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .sf-preview {
    width: 100%;
    max-height: 45vh;
  }
  .sf-header {
    flex-wrap: wrap;
    padding: 10px 12px;
  }
  .sf-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* 📱 手機版 SoulForge 字體與操作優化 */
@media (max-width: 480px) {
  .sf-header {
    padding: 8px 10px;
    gap: 6px;
  }
  .sf-title .sf-logo { font-size: 18px; }
  .sf-title span:last-child { font-size: 15px; }
  .sf-actions .tool-btn {
    font-size: 10px !important;
    padding: 3px 6px !important;
  }
  .sf-cost-badge {
    font-size: 10px;
    padding: 2px 6px;
  }
  .sf-chat-header {
    padding: 6px 12px;
    font-size: 11px;
  }
  .sf-messages {
    padding: 10px 12px;
    gap: 8px;
  }
  .sf-msg-content {
    padding: 8px 12px;
    font-size: 13px;
  }
  .sf-msg { max-width: 92%; }
  .sf-input-row {
    padding: 8px 10px;
    gap: 6px;
  }
  .sf-input-row input {
    padding: 8px 12px;
    font-size: 13px;
  }
  .sf-input-row button {
    padding: 8px 14px;
    font-size: 13px;
  }
  .sf-preview-header {
    padding: 6px 12px;
    font-size: 11px;
  }
  .sf-card {
    padding: 12px;
    gap: 8px;
  }
  .sf-avatar-preview { padding: 4px 12px; }
  .sf-avatar-preview img { width: 120px; height: 160px; }
  .sf-field-label { font-size: 10px; }
  .sf-field-input {
    padding: 6px 8px;
    font-size: 12px;
  }
  .sf-lock-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  .sf-batch-btn {
    font-size: 10px;
    padding: 5px 6px;
  }
}
}

/* ═══════════════════════════════════════
   🔥 歡迎頁面樣式
   ═══════════════════════════════════════ */
#welcome-view {
  display: none;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}
.welcome-hero {
  text-align: center;
  padding: 60px 20px 30px;
  background-image: url('../background/bg-welcome-desktop.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
}
.welcome-logo {
  font-size: 80px;
  margin-bottom: 12px;
  animation: welcome-glow 3s ease-in-out infinite;
}
@keyframes welcome-glow {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(168,85,247,0.4)); }
  50% { filter: drop-shadow(0 0 40px rgba(251,191,36,0.6)); }
}
.welcome-title {
  font-size: 48px;
  font-weight: 800;
  margin: 0 0 12px 0;
  background: linear-gradient(135deg, #c084fc 0%, #fbbf24 50%, #f472b6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.welcome-tagline {
  font-size: 18px;
  color: rgba(255,255,255,0.8);
  margin: 0 0 8px 0;
  font-weight: 500;
}
.welcome-subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.4);
  margin: 0 0 32px 0;
}
.welcome-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.welcome-btn {
  padding: 12px 24px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: #e0e0e0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
}
.welcome-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.3);
  transform: translateY(-1px);
}
.welcome-btn.primary {
  background: linear-gradient(135deg, rgba(168,85,247,0.3), rgba(139,92,246,0.2));
  border-color: rgba(168,85,247,0.4);
  color: #c084fc;
}
.welcome-btn.primary:hover {
  background: linear-gradient(135deg, rgba(168,85,247,0.5), rgba(139,92,246,0.3));
}
.welcome-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 0 0 60px;
}
.welcome-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 24px;
  transition: all 0.2s;
}
.welcome-card:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.15);
  transform: translateY(-2px);
}
.welcome-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 12px;
}
.welcome-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: #e0e0e0;
}
.welcome-card p {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  margin: 0;
  line-height: 1.6;
}
/* 📱 手機版：定價+福利改單欄 */
@media (max-width: 768px) {
  .welcome-pricing-grid {
    grid-template-columns: 1fr !important;
  }
}

/* 手機版歡迎頁面 */
@media (max-width: 768px) {
  .welcome-hero {
    padding: 50px 16px 30px;
    background-image: url('../background/bg-stars-mobile.png');
    background-size: cover;
    background-position: center;
  }
  .welcome-logo { font-size: 56px; }
  .welcome-title { font-size: 32px; }
  .welcome-tagline { font-size: 15px; }
  .welcome-features { grid-template-columns: 1fr; gap: 10px; padding: 0 16px 40px; }
  .welcome-card { padding: 16px; }
  .welcome-btn { padding: 10px 18px; font-size: 13px; }
}

/* ═══════════════════════════════════════
   🖼️ 全站背景圖系統（RWD 自動切換）
   ═══════════════════════════════════════ */

/* ── 歡迎頁背景：科幻控制室 ── */
#welcome-view {
  background-color: #0a1628; background-image: linear-gradient(rgba(10,22,40,0.45), rgba(10,22,40,0.5)),
              url('/static/background/bg-welcome-desktop.png');
  background-size: cover;
  background-position: center;
  background-attachment: scroll;
  min-height: 100vh;
}
/* 手機版：切換直幅 */
@media (max-width: 768px) {
  #welcome-view {
    background-color: #0a1628; background-image: linear-gradient(rgba(10,22,40,0.45), rgba(10,22,40,0.5)),
                url('/static/background/bg-stars-mobile.png');
    background-size: cover;
    background-position: center;
    background-attachment: scroll;
  }
}

/* ── 靈魂熔爐背景：霓虹熔爐 + 深色遮罩（保留文字清晰度）── */
#soulforge-view {
  background-color: #0a1628; background-image: linear-gradient(rgba(10,22,40,0.75), rgba(5,12,24,0.8)),
              url('/static/background/bg-forge2-desktop.png');
  background-size: cover;
  background-position: center;
  background-attachment: scroll;
}
@media (max-width: 768px) {
  #soulforge-view {
    background-color: #0a1628; background-image: linear-gradient(rgba(10,22,40,0.75), rgba(5,12,24,0.8)),
                url('/static/background/bg-forge-mobile.png');
    background-size: cover;
    background-position: center;
    background-attachment: scroll;
  }
}

/* ── 大廳背景：星塵漩渦 · 極重遮罩（不搶角色卡片風采）── */
#lobby-view {
  background-color: #0a1628; background-image: linear-gradient(rgba(10,22,40,0.82), rgba(5,12,24,0.85)),
              url('/static/background/bg-stars-desktop.png');
  background-size: cover;
  background-position: center;
  background-attachment: scroll;
}
@media (max-width: 768px) {
  #lobby-view {
    background-color: #0a1628; background-image: linear-gradient(rgba(10,22,40,0.82), rgba(5,12,24,0.85)),
                url('/static/background/bg-stars-mobile.png');
    background-size: cover;
    background-position: center;
    background-attachment: scroll;
  }
}

/* ── 市集背景：同大廳星塵漩渦 ── */
#marketplace-view {
  background-color: #0a1628; background-image: linear-gradient(rgba(10,22,40,0.82), rgba(5,12,24,0.85)),
              url('/static/background/bg-stars-desktop.png');
  background-size: cover;
  background-position: center;
  background-attachment: scroll;
}
@media (max-width: 768px) {
  #marketplace-view {
    background-color: #0a1628; background-image: linear-gradient(rgba(10,22,40,0.82), rgba(5,12,24,0.85)),
                url('/static/background/bg-stars-mobile.png');
    background-size: cover;
    background-position: center;
    background-attachment: scroll;
  }
}

/* ── 聊天室背景：角色立繪模糊（由 JS 動態設定）── */
#chat-view {
  background-size: cover;
  background-position: center;
  background-attachment: scroll;
  transition: background-image 0.6s ease-in-out;
}
/* 預設無角色時，用純深色漸層 */
#chat-view.chat-bg-default {
  background: linear-gradient(135deg, #0a1628, #1a2744, #0f1f3a);
}
/* 角色立繪模糊背景：JS 會設定 inline style + 此 class */
#chat-view.chat-bg-character {
  background-size: cover;
  background-position: center top;
  background-attachment: scroll;
}
/* 模糊層：放在聊天室內部，不影響文字 */
.chat-bg-blur-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center top;
  filter: blur(24px) brightness(0.35);
  opacity: 0.85;
  transition: background-image 0.8s ease-in-out;
}
/* 手機版稍微降低模糊強度 */
@media (max-width: 768px) {
  #chat-view { background-attachment: scroll; }
  .chat-bg-blur-layer {
    filter: blur(16px) brightness(0.3);
    background-attachment: scroll;
  }
}
