/* ==================== 登录页 ==================== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-overlay.hidden {
    display: none;
}

.login-box {
    text-align: center;
    padding: 40px;
    max-width: 320px;
    width: 100%;
}

.login-logo {
    font-size: 48px;
    color: var(--accent-purple);
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.login-input:focus {
    border-color: var(--accent-purple);
}

.login-input::placeholder {
    color: var(--text-muted);
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.login-btn:hover {
    opacity: 0.9;
}

.login-btn:active {
    transform: scale(0.98);
}

.login-error {
    color: #ff6b6b;
    font-size: 13px;
    margin: 0;
}

.login-error.hidden {
    display: none;
}

/* ==================== CSS Variables ==================== */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a28;
    --bg-card-hover: #22223a;
    --bg-input: #1e1e2e;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    --bg-nav: rgba(18, 18, 26, 0.95);

    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #686880;
    --text-accent: #c4a0ff;

    --accent-purple: #8b5cf6;
    --accent-purple-light: #a78bfa;
    --accent-pink: #ec4899;
    --accent-gradient: linear-gradient(135deg, #8b5cf6, #ec4899);
    --accent-gradient-h: linear-gradient(90deg, #8b5cf6, #ec4899);

    --rarity-r: #a0a0b8;
    --rarity-sr: #f0b040;
    --rarity-ssr: linear-gradient(135deg, #ff6b6b, #ffd93d, #6bff6b, #6b9dff, #d06bff);

    --border-color: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.3);

    --font-xs: 11px;
    --font-sm: 13px;
    --font-md: 15px;
    --font-lg: 18px;
    --font-xl: 22px;
    --font-xxl: 28px;

    --nav-height: 64px;
    --top-bar-height: 56px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== Reset & Base ==================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100%;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

/* ==================== Top Bar ==================== */
.top-bar {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--top-bar-height); padding: 0 16px;
    background: var(--bg-secondary); border-bottom: 1px solid var(--border-color);
    flex-shrink: 0; z-index: 100;
}
.top-bar-left { display: flex; align-items: center; gap: 8px; }
.app-logo { font-size: 22px; background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.app-title { font-size: var(--font-lg); font-weight: 700; background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.top-bar-right { display: flex; align-items: center; gap: 12px; }
.currency { display: flex; gap: 10px; font-size: var(--font-sm); }
.coin { display: flex; align-items: center; gap: 3px; padding: 2px 8px; background: var(--bg-card); border-radius: var(--radius-full); font-weight: 600; }
.coin.silver { color: #c0c0d0; }
.coin.gold { color: #ffd700; }
.icon-btn { background: none; border: none; color: var(--text-secondary); font-size: var(--font-lg); cursor: pointer; padding: 4px; border-radius: var(--radius-sm); transition: var(--transition); }
.icon-btn:hover { color: var(--text-primary); background: var(--bg-card); }

/* ==================== Page Content ==================== */
.page-content { flex: 1; overflow: hidden; position: relative; }
.page { display: none; height: 100%; overflow-y: auto; padding-bottom: 16px; }
.page.active { display: block; }
.page::-webkit-scrollbar { width: 4px; }
.page::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 2px; }

/* ==================== Bottom Navigation ==================== */
.bottom-nav {
    display: flex; align-items: center; justify-content: space-around;
    height: var(--nav-height); background: var(--bg-nav);
    border-top: 1px solid var(--border-color); flex-shrink: 0; z-index: 100;
    backdrop-filter: blur(20px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 8px 16px; border-radius: var(--radius-md); transition: var(--transition); position: relative;
}
.nav-item.active { color: var(--accent-purple-light); }
.nav-item:hover { color: var(--text-secondary); }
.nav-icon { font-size: 22px; }
.nav-label { font-size: var(--font-xs); font-weight: 500; }
.nav-badge {
    position: absolute; top: 2px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px;
    background: var(--accent-pink); color: white; font-size: 10px; font-weight: 700;
    border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center;
}

/* ==================== Category Navigation ==================== */
.category-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 10;
}
.category-tabs { display: flex; gap: 4px; }
.tab {
    background: none; border: none; color: var(--text-secondary); font-size: var(--font-md); font-weight: 500;
    padding: 6px 14px; border-radius: var(--radius-full); cursor: pointer; transition: var(--transition); position: relative;
}
.tab.active { color: var(--text-primary); background: rgba(139, 92, 246, 0.15); }
.tab.active::after { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 20px; height: 2px; background: var(--accent-gradient-h); border-radius: 1px; }
.filter-btn {
    display: flex; align-items: center; gap: 4px; background: var(--bg-card);
    border: 1px solid var(--border-light); color: var(--text-secondary); font-size: var(--font-sm);
    padding: 6px 12px; border-radius: var(--radius-full); cursor: pointer; transition: var(--transition);
}
.filter-btn:hover { border-color: var(--accent-purple); color: var(--text-primary); }
.filter-icon { font-size: 14px; }

/* ==================== Role Card Grid ==================== */
.role-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px 16px; }
.role-card {
    background: var(--bg-card); border-radius: var(--radius-lg); overflow: hidden;
    cursor: pointer; transition: var(--transition); border: 1px solid var(--border-color); position: relative;
}
.role-card:hover { transform: translateY(-2px); border-color: var(--accent-purple); box-shadow: var(--shadow-glow); }
.role-card-cover { width: 100%; height: 180px; object-fit: cover; display: block; }
.role-card-cover-placeholder {
    width: 100%; height: 180px; display: flex; align-items: center; justify-content: center;
    font-size: 48px; background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
}
.role-card-rarity {
    position: absolute; top: 8px; left: 8px; padding: 2px 8px;
    border-radius: var(--radius-sm); font-size: var(--font-xs); font-weight: 800; letter-spacing: 1px;
}
.rarity-r { background: rgba(160, 160, 184, 0.3); color: var(--rarity-r); }
.rarity-sr { background: rgba(240, 176, 64, 0.2); color: var(--rarity-sr); }
.rarity-ssr { background: var(--rarity-ssr); color: #fff; }
.role-card-new {
    position: absolute; top: 8px; right: 8px; padding: 2px 8px;
    border-radius: var(--radius-sm); font-size: var(--font-xs); font-weight: 600;
    background: var(--accent-purple); color: white;
}
.role-card-info { padding: 10px; }
.role-card-title { font-size: var(--font-md); font-weight: 600; color: var(--text-primary); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-card-desc { font-size: var(--font-xs); color: var(--text-secondary); margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.role-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.role-card-tag { padding: 2px 6px; border-radius: var(--radius-sm); font-size: 10px; background: rgba(139, 92, 246, 0.15); color: var(--accent-purple-light); border: 1px solid rgba(139, 92, 246, 0.2); }
.role-card-footer { display: flex; justify-content: space-between; align-items: center; font-size: var(--font-xs); color: var(--text-muted); }
.role-card-author { color: var(--text-secondary); }
.role-card-heat { display: flex; align-items: center; gap: 3px; color: #ff6b6b; }

/* ==================== Filter Modal ==================== */
.filter-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 200; }
.filter-modal.active { display: flex; }
.filter-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-overlay); }
.filter-panel {
    position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px; max-height: 80%;
    background: var(--bg-secondary); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    display: flex; flex-direction: column; animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateX(-50%) translateY(100%); } to { transform: translateX(-50%) translateY(0); } }
.filter-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
.filter-header h3 { font-size: var(--font-lg); font-weight: 600; }
.filter-actions { display: flex; align-items: center; gap: 12px; }
.filter-count { font-size: var(--font-sm); color: var(--text-secondary); }
.reset-btn { background: none; border: none; color: var(--accent-purple-light); font-size: var(--font-sm); cursor: pointer; }
.filter-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.filter-group { margin-bottom: 20px; }
.filter-group h4 { font-size: var(--font-sm); color: var(--text-secondary); margin-bottom: 10px; font-weight: 600; }
.filter-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-tag {
    padding: 6px 14px; border-radius: var(--radius-full); font-size: var(--font-sm);
    background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border-color);
    cursor: pointer; transition: var(--transition);
}
.filter-tag.active { background: rgba(139, 92, 246, 0.2); color: var(--accent-purple-light); border-color: var(--accent-purple); }
.filter-footer { display: flex; gap: 12px; padding: 16px 20px; border-top: 1px solid var(--border-color); }
.btn-cancel, .btn-confirm { flex: 1; padding: 12px; border-radius: var(--radius-md); font-size: var(--font-md); font-weight: 600; cursor: pointer; border: none; transition: var(--transition); }
.btn-cancel { background: var(--bg-card); color: var(--text-secondary); }
.btn-confirm { background: var(--accent-gradient); color: white; }
.btn-confirm:hover { opacity: 0.9; transform: scale(1.01); }

/* ==================== Chat List ==================== */
.chat-list-view { height: 100%; display: flex; flex-direction: column; }
.chat-list-header { padding: 16px 20px; border-bottom: 1px solid var(--border-color); }
.chat-list-header h2 { font-size: var(--font-xl); font-weight: 700; }
.chat-list { flex: 1; overflow-y: auto; padding: 8px 16px; }
.chat-list-item {
    display: flex; align-items: center; gap: 12px; padding: 14px 12px;
    border-radius: var(--radius-md); cursor: pointer; transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}
.chat-list-item:hover { background: var(--bg-card); }
.chat-list-item-avatar { width: 48px; height: 48px; border-radius: var(--radius-full); object-fit: cover; flex-shrink: 0; }
.chat-list-item-avatar-placeholder {
    width: 48px; height: 48px; border-radius: var(--radius-full);
    display: flex; align-items: center; justify-content: center; font-size: 24px;
    background: var(--accent-gradient); flex-shrink: 0;
}
.chat-list-item-content { flex: 1; min-width: 0; }
.chat-list-item-title { font-size: var(--font-md); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list-item-preview { font-size: var(--font-sm); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-list-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.chat-list-item-time { font-size: var(--font-xs); color: var(--text-muted); }
.chat-list-item-status { font-size: var(--font-xs); color: var(--accent-purple-light); background: rgba(139, 92, 246, 0.15); padding: 2px 8px; border-radius: var(--radius-full); }
.chat-list-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text-muted); }
.chat-list-empty .empty-icon { font-size: 48px; opacity: 0.5; }
.chat-list-empty p { font-size: var(--font-md); }
.chat-list-empty .empty-hint { font-size: var(--font-sm); color: var(--text-muted); }

/* ==================== Chat View ==================== */
.chat-view { height: 100%; display: flex; flex-direction: column; }
.chat-view.hidden { display: none; }
.chat-header {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.back-btn { background: none; border: none; color: var(--text-secondary); font-size: var(--font-xl); cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); transition: var(--transition); }
.back-btn:hover { color: var(--text-primary); background: var(--bg-card); }
.chat-role-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.chat-role-avatar { width: 36px; height: 36px; border-radius: var(--radius-full); object-fit: cover; }
.chat-role-detail { display: flex; flex-direction: column; }
.chat-role-name { font-size: var(--font-md); font-weight: 600; }
.chat-role-status { font-size: var(--font-xs); color: #4ade80; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 2px; }
.message { display: flex; gap: 8px; max-width: 85%; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.ai { align-self: flex-start; }
.message-avatar { width: 32px; height: 32px; border-radius: var(--radius-full); object-fit: cover; flex-shrink: 0; }
.message-avatar-placeholder { width: 32px; height: 32px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.message.ai .message-avatar-placeholder { background: var(--accent-gradient); }
.message.user .message-avatar-placeholder { background: var(--bg-card); border: 1px solid var(--border-light); }
.message-bubble { padding: 10px 14px; border-radius: var(--radius-lg); font-size: var(--font-md); line-height: 1.6; word-break: break-word; }
.message.ai .message-bubble { background: var(--bg-card); color: var(--text-primary); border-bottom-left-radius: 4px; }
.message.user .message-bubble { background: var(--accent-gradient); color: white; border-bottom-right-radius: 4px; }
.message-time { font-size: var(--font-xs); color: var(--text-muted); margin-top: 4px; text-align: right; }
.message.ai .message-time { text-align: left; }

/* Typing indicator */
.typing-indicator { display: flex; gap: 4px; padding: 12px 16px; }
.typing-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); animation: typingBounce 1.4s infinite ease-in-out; }
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

/* ==================== Chat Input ==================== */
.chat-input-area { padding: 12px 16px; background: var(--bg-secondary); border-top: 1px solid var(--border-color); flex-shrink: 0; }
.chat-input-wrapper {
    display: flex; align-items: flex-end; gap: 8px; background: var(--bg-input);
    border-radius: var(--radius-lg); padding: 6px 6px 6px 14px;
    border: 1px solid var(--border-color); transition: var(--transition);
}
.chat-input-wrapper:focus-within { border-color: var(--accent-purple); box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15); }
.chat-input { flex: 1; background: none; border: none; color: var(--text-primary); font-size: var(--font-md); resize: none; outline: none; max-height: 120px; line-height: 1.5; font-family: inherit; }
.chat-input::placeholder { color: var(--text-muted); }
.send-btn {
    width: 36px; height: 36px; border-radius: var(--radius-full); background: var(--accent-gradient);
    border: none; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: var(--transition); flex-shrink: 0;
}
.send-btn:hover { opacity: 0.9; transform: scale(1.05); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.send-icon { font-size: 16px; }

/* ==================== Role Detail Modal ==================== */
.role-detail-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 300; display: flex; align-items: flex-end; justify-content: center; }
.role-detail-modal.hidden { display: none; }
.role-detail-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-overlay); }
.role-detail-panel {
    position: relative; width: 100%; max-width: 480px; height: 85%;
    background: var(--bg-secondary); border-radius: var(--radius-xl) var(--radius-xl) 0 0; overflow: hidden; animation: bottomSheetUp 0.3s ease;
    display: flex; flex-direction: column;
}
@keyframes bottomSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.close-btn {
    position: absolute; top: 12px; right: 12px; width: 32px; height: 32px;
    border-radius: var(--radius-full); background: rgba(0, 0, 0, 0.5); border: none;
    color: white; font-size: var(--font-md); cursor: pointer; z-index: 1;
    display: flex; align-items: center; justify-content: center;
}
.role-detail-hero { position: relative; height: 160px; overflow: hidden; }
.role-detail-avatar { width: 100%; height: 100%; object-fit: cover; }
.role-detail-rarity { position: absolute; top: 12px; left: 12px; padding: 4px 12px; border-radius: var(--radius-sm); font-size: var(--font-sm); font-weight: 800; letter-spacing: 1px; }
.role-detail-info { padding: 20px; overflow-y: auto; flex: 1; min-height: 0; }
.role-detail-name { font-size: var(--font-xl); font-weight: 700; margin-bottom: 8px; }
.role-detail-desc { font-size: var(--font-sm); color: var(--text-secondary); line-height: 1.6; margin-bottom: 12px; }
.role-detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.role-detail-meta { display: flex; justify-content: space-between; font-size: var(--font-sm); color: var(--text-muted); }
.role-detail-actions { display: flex; gap: 12px; padding: 16px 20px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border-color); }
.btn-start-chat { flex: 2; padding: 12px; border-radius: var(--radius-md); background: var(--accent-gradient); color: white; font-size: var(--font-md); font-weight: 600; border: none; cursor: pointer; transition: var(--transition); }
.btn-start-chat:hover { opacity: 0.9; transform: scale(1.02); }
.btn-collect { flex: 1; padding: 12px; border-radius: var(--radius-md); background: var(--bg-card); color: var(--text-secondary); font-size: var(--font-md); font-weight: 600; border: 1px solid var(--border-light); cursor: pointer; transition: var(--transition); }
.btn-collect:hover { border-color: var(--accent-pink); color: var(--accent-pink); }
.btn-collect.collected { color: var(--accent-pink); border-color: var(--accent-pink); background: rgba(236, 72, 153, 0.1); }

/* 玩法规则区域 */
.role-detail-info { flex: 1; min-height: 0; }
.rules-section { margin-top: 16px; }
.rules-title { font-size: var(--font-md); font-weight: 700; color: var(--accent-purple-light); margin-bottom: 12px; }
.rules-block { margin-bottom: 14px; background: rgba(139, 92, 246, 0.08); border-radius: var(--radius-md); padding: 12px; border: 1px solid rgba(139, 92, 246, 0.15); }
.rules-block-title { font-size: var(--font-sm); font-weight: 700; color: var(--accent-purple-light); margin-bottom: 8px; }
.rules-block-content { display: flex; flex-direction: column; gap: 4px; }
.rules-item { font-size: var(--font-xs); color: var(--text-secondary); line-height: 1.6; padding-left: 4px; }
.rules-num { color: var(--accent-pink); font-weight: 700; margin-right: 4px; }

/* 聊天菜单 */
.chat-menu-dropdown {
    position: absolute; top: 44px; right: 12px;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    z-index: 100; min-width: 140px; overflow: hidden;
    animation: menuFadeIn 0.15s ease;
}
@keyframes menuFadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.chat-menu-item {
    display: block; width: 100%; padding: 12px 16px; background: none; border: none;
    color: var(--text-secondary); font-size: var(--font-sm); text-align: left; cursor: pointer;
    transition: var(--transition);
}
.chat-menu-item:hover { background: rgba(139, 92, 246, 0.1); color: var(--text-primary); }
.chat-menu-item.danger { color: #ef4444; }
.chat-menu-item.danger:hover { background: rgba(239, 68, 68, 0.1); }

/* 消息删除按钮 */
.msg-delete-btn {
    position: absolute; top: 4px; right: 4px;
    width: 24px; height: 24px; border-radius: var(--radius-full);
    background: rgba(239, 68, 68, 0.9); color: white; border: none;
    font-size: 12px; cursor: pointer; display: none;
    align-items: center; justify-content: center; z-index: 10;
}
.delete-mode .message { position: relative; }
.delete-mode .msg-delete-btn { display: flex; }
.delete-mode .message:hover { opacity: 0.7; }

/* ==================== Draw Page ==================== */
.draw-page-content { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 16px; text-align: center; padding: 20px; }
.draw-page-content h2 { font-size: var(--font-xl); font-weight: 700; }
.draw-hint { color: var(--text-secondary); font-size: var(--font-md); }
.draw-placeholder { font-size: 64px; opacity: 0.3; }

/* ==================== Mine Page ==================== */
.mine-header { padding: 20px 16px; background: var(--bg-secondary); }
.user-card { display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 56px; height: 56px; border-radius: var(--radius-full); background: var(--accent-gradient); display: flex; align-items: center; justify-content: center; font-size: var(--font-xl); font-weight: 700; color: white; flex-shrink: 0; }
.user-info { flex: 1; display: flex; flex-direction: column; }
.user-name { font-size: var(--font-lg); font-weight: 600; }
.user-id { font-size: var(--font-xs); color: var(--text-muted); }
.wallet-btn { padding: 8px 16px; border-radius: var(--radius-full); background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border-light); font-size: var(--font-sm); cursor: pointer; transition: var(--transition); }
.wallet-btn:hover { border-color: var(--accent-purple); color: var(--text-primary); }
.mine-shortcuts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 16px; }
.shortcut-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-secondary); cursor: pointer; transition: var(--transition); }
.shortcut-btn:hover { border-color: var(--accent-purple); color: var(--text-primary); }
.shortcut-icon { font-size: 22px; }
.shortcut-btn span:last-child { font-size: var(--font-xs); }
.mine-tabs { display: flex; padding: 0 16px; border-bottom: 1px solid var(--border-color); }
.mine-tab { background: none; border: none; color: var(--text-secondary); font-size: var(--font-md); font-weight: 500; padding: 12px 20px; cursor: pointer; position: relative; transition: var(--transition); }
.mine-tab.active { color: var(--text-primary); }
.mine-tab.active::after { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 30px; height: 2px; background: var(--accent-gradient-h); border-radius: 1px; }
.mine-content { padding: 20px 16px; }
.collection-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 40px 0; color: var(--text-muted); }
.collection-empty .empty-icon { font-size: 48px; opacity: 0.5; }
.collection-empty p { font-size: var(--font-md); }
.collection-empty .empty-hint { font-size: var(--font-sm); }
.collection-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.collection-grid.hidden { display: none; }

/* ==================== Settings Panel ==================== */
.settings-panel {
    position: fixed; top: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px; height: 100%;
    background: var(--bg-primary); z-index: 400; overflow-y: auto;
}
.settings-panel.hidden { display: none; }
.settings-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 1; }
.settings-header h3 { font-size: var(--font-lg); font-weight: 600; }
.settings-body { padding: 20px 16px; display: flex; flex-direction: column; gap: 20px; }
.setting-item { display: flex; flex-direction: column; gap: 8px; }
.setting-label { font-size: var(--font-sm); color: var(--text-secondary); font-weight: 500; }
.setting-input, .setting-textarea {
    padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); color: var(--text-primary); font-size: var(--font-md);
    font-family: inherit; outline: none; transition: var(--transition);
}
.setting-input:focus, .setting-textarea:focus { border-color: var(--accent-purple); box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15); }
.setting-textarea { resize: vertical; min-height: 80px; }
.setting-range { width: 100%; accent-color: var(--accent-purple); }
.setting-value { font-size: var(--font-sm); color: var(--accent-purple-light); font-weight: 600; }
.btn-save-settings {
    padding: 14px; border-radius: var(--radius-md); background: var(--accent-gradient);
    color: white; font-size: var(--font-md); font-weight: 600; border: none;
    cursor: pointer; transition: var(--transition); margin-top: 8px;
}
.btn-save-settings:hover { opacity: 0.9; transform: scale(1.01); }

/* ==================== Toast ==================== */
.toast {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    padding: 10px 24px; background: var(--bg-card); color: var(--text-primary);
    border-radius: var(--radius-full); font-size: var(--font-sm);
    box-shadow: var(--shadow-lg); z-index: 500; animation: toastIn 0.3s ease;
    border: 1px solid var(--border-light);
}
.toast.hidden { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ==================== Responsive ==================== */
@media (min-width: 481px) {
    #app { border-left: 1px solid var(--border-color); border-right: 1px solid var(--border-color); }
}

/* ==================== Scrollbar Global ==================== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 2px; }

/* ==================== Selection ==================== */
::selection { background: rgba(139, 92, 246, 0.3); color: var(--text-primary); }


/* ==================== Search Bar ==================== */
.search-bar {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 16px;
    z-index: 150;
    animation: slideDown 0.2s ease;
}
.search-bar.hidden { display: none; }
@keyframes slideDown { from { transform: translateX(-50%) translateY(-100%); } to { transform: translateX(-50%) translateY(0); } }
.search-bar-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    padding: 6px 12px;
    border: 1px solid var(--border-color);
}
.search-bar-inner .search-icon { font-size: 16px; flex-shrink: 0; }
.search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: var(--font-md);
    outline: none;
    font-family: inherit;
}
.search-input::placeholder { color: var(--text-muted); }
.search-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: var(--font-md);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}
.search-clear.hidden { display: none; }
.search-cancel {
    background: none;
    border: none;
    color: var(--accent-purple-light);
    font-size: var(--font-md);
    cursor: pointer;
    padding: 4px 8px;
    white-space: nowrap;
}
.search-results-hint {
    padding: 12px 16px;
    font-size: var(--font-sm);
    color: var(--text-muted);
    text-align: center;
}

/* ==================== Mine Section Title ==================== */
.mine-section-title {
    padding: 16px 16px 8px;
    font-size: var(--font-md);
    font-weight: 600;
    color: var(--text-secondary);
}

/* ==================== Quick Replies ==================== */
.quick-replies {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 6px 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: relative;
}
.quick-replies::-webkit-scrollbar { display: none; }
.quick-reply-btn {
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: 16px;
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.quick-reply-btn:active {
    background: var(--accent-purple);
    color: #fff;
    border-color: var(--accent-purple);
    transform: scale(0.95);
}
/* 滑动提示渐变遮罩 */
.quick-replies::after {
    content: '';
    position: sticky;
    right: 0;
    flex-shrink: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, var(--bg-secondary));
    pointer-events: none;
}

/* ==================== Custom Role Tag Select ==================== */
.cr-tags-select {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px;
}
.cr-tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.cr-tag-group-label {
    font-size: 11px;
    color: var(--text-muted);
    width: 100%;
    margin-bottom: -2px;
}
.cr-tag-btn {
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.cr-tag-btn.selected {
    background: var(--accent-purple);
    color: #fff;
    border-color: var(--accent-purple);
}

/* ==================== Custom Role Card (Mine Page) ==================== */
.custom-role-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.15s ease;
}
.custom-role-card:active {
    transform: scale(0.98);
}
.custom-role-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.custom-role-info .role-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.custom-role-info .role-card-desc {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.custom-role-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.cr-action-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.15s ease;
}
.cr-action-btn:active {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
}

/* ==================== Scene Selector ==================== */
.scene-selector {
    margin-top: 12px;
}
.scene-selector-title {
    font-size: var(--font-md);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.scene-count {
    font-size: var(--font-sm);
    color: var(--text-muted);
    font-weight: 400;
}
.scene-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 50%;
    overflow-y: auto;
}
.scene-item {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.15s ease;
}
.scene-item.selected {
    border-color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.1);
}
.scene-item:active {
    transform: scale(0.98);
}
.scene-item-label {
    display: inline-block;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    margin-bottom: 4px;
}
.scene-item.selected .scene-item-label {
    background: var(--accent-purple);
    color: #fff;
}
.scene-item-text {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.btn-continue-chat {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--accent-purple);
    background: transparent;
    color: var(--accent-purple);
    font-size: var(--font-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-continue-chat:active {
    background: rgba(139, 92, 246, 0.1);
}
