:root {
    --primary: #4F46E5;
    --primary-light: #6366F1;
    --primary-dark: #3730A3;
    --primary-glow: rgba(79, 70, 229, 0.3);
    --bg: #FAFBFC;
    --bg-card: #FFFFFF;
    --bg-input: #F3F4F6;
    --text: #1F2937;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --primary: #818CF8;
    --primary-light: #A5B4FC;
    --primary-dark: #6366F1;
    --primary-glow: rgba(129, 140, 248, 0.35);
    --bg: #0F172A;
    --bg-card: #1E293B;
    --bg-input: #334155;
    --text: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border: #334155;
    --border-light: #1E293B;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

html {
    background: var(--bg);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'SF Pro Display', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
    -webkit-font-smoothing: antialiased;
}

/* ==================== 导航栏 ==================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    transition: all var(--transition);
    animation: slideDown 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    height: 60px;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    user-select: none;
}

.logo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
}

.nav-item {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.nav-item:hover { color: var(--text); background: var(--bg-input); }

.nav-item.active {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
}

.nav-item .nav-underline {
    position: absolute;
    bottom: -1px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-item.active .nav-underline {
    left: 10%;
    width: 80%;
}

.nav-icon { font-size: 1.1rem; }

.theme-toggle {
    background: var(--bg-input);
    border: none;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-size: 1.1rem;
}

.theme-toggle:hover { background: var(--border); transform: rotate(15deg); }
.theme-toggle:active { transform: rotate(30deg) scale(0.9); }

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.menu-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all var(--transition);
}

/* ==================== 主内容区 ==================== */
.main-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 80px 1.5rem 2rem;
    min-height: calc(100vh - 60px);
}

.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== 主页 ==================== */
.home-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
    padding-top: 2rem;
}

/* 头像 */
.avatar-section {
    position: relative;
    animation: floatIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes floatIn {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.avatar-wrapper { position: relative; }

.avatar-glow {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: var(--primary-glow);
    filter: blur(20px);
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 1; }
}

.avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 3px solid var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    z-index: 1;
    overflow: hidden;
    transition: all var(--transition);
}

.avatar:hover {
    transform: scale(1.05);
    border-color: var(--primary);
    box-shadow: 0 0 30px var(--primary-glow);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder { font-size: 2.5rem; background: linear-gradient(135deg, #f59e0b, #d97706); width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: white; }

.avatar-edit {
    position: absolute;
    bottom: 2px;
    right: 2px;
    z-index: 2;
    background: var(--primary);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.75rem;
    opacity: 0;
    transform: scale(0.5);
    transition: all var(--transition);
    box-shadow: var(--shadow);
}

.avatar-wrapper:hover .avatar-edit {
    opacity: 1;
    transform: scale(1);
}

/* 座右铭 */
.motto-section {
    text-align: center;
    animation: floatIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.15s backwards;
}

.motto {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    outline: none;
    transition: all var(--transition);
    min-width: 200px;
}

.motto:hover { background: var(--bg-input); }

.motto:focus {
    background: var(--bg-input);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.motto-edit-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    opacity: 0;
    transition: opacity var(--transition);
}

.motto:hover + .motto-edit-hint,
.motto:focus + .motto-edit-hint { opacity: 1; }

/* 标题装饰线 */
.section-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 600;
    animation: floatIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.3s backwards;
}

.title-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border), transparent);
}

/* 联系卡片 */
.contacts-section { width: 100%; }

.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    animation: floatIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.4s backwards;
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.contact-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.contact-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.contact-card:hover::before { opacity: 0.03; }

.contact-card:active { transform: translateY(0) scale(0.98); }

.contact-icon {
    width: 44px;
    height: 44px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    transition: all var(--transition);
}

.contact-card:hover .contact-icon {
    background: rgba(79, 70, 229, 0.1);
    transform: scale(1.1);
}

.contact-info { flex: 1; }

.contact-info h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.contact-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
}

.contact-action {
    background: var(--bg-input);
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 500;
    transition: all var(--transition);
}

.contact-action:hover { background: var(--primary); color: white; }

.add-contact {
    border-style: dashed;
    justify-content: center;
    opacity: 0.6;
}

.add-contact:hover { opacity: 1; }

.add-contact .contact-icon {
    background: transparent;
    font-size: 1.5rem;
    color: var(--text-muted);
}

/* 公告栏 */
.announcement-section { width: 100%; }

.announcement-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    animation: floatIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.5s backwards;
    transition: all var(--transition);
    box-shadow: var(--shadow);
}

.announcement-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.announcement-header {
    padding: 1.25rem 1.5rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.announcement-pin {
    font-size: 1.2rem;
    flex-shrink: 0;
    animation: pinBounce 2s ease-in-out infinite;
}

@keyframes pinBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.announcement-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.02em;
}

.announcement-content {
    padding: 0 1.5rem 1.25rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.7;
    white-space: pre-wrap;
}

.announcement-image {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    display: block;
    border-top: 1px solid var(--border-light);
}

.announcement-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* 博客占位 */
.blog-section { width: 100%; }

.blog-placeholder {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    animation: floatIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.5s backwards;
}

.placeholder-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow: hidden;
}

.placeholder-shimmer {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    margin-bottom: 1rem;
    animation: shimmer 2s ease-in-out infinite;
}

.placeholder-title {
    height: 14px;
    width: 60%;
    background: var(--bg-input);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    animation: shimmer 2s ease-in-out infinite 0.3s;
}

.placeholder-content {
    height: 10px;
    width: 80%;
    background: var(--bg-input);
    border-radius: 4px;
    animation: shimmer 2s ease-in-out infinite 0.6s;
}

@keyframes shimmer {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ==================== 聊天视图 ==================== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.5s ease;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(79, 70, 229, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    animation: avatarBounce 3s ease-in-out infinite;
}

@keyframes avatarBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.chat-title h2 { font-size: 1rem; font-weight: 600; }

.chat-status { display: flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; color: var(--text-secondary); }

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22C55E;
}

.status-dot.online { animation: statusPulse 2s ease-in-out infinite; }

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.chat-actions { display: flex; gap: 0.5rem; }

.btn-icon {
    background: var(--bg-input);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-icon:hover { background: var(--border); transform: translateY(-1px); }
.btn-icon:active { transform: scale(0.95); }

/* 消息容器 */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 4px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* 欢迎消息 */
.welcome-message { text-align: center; }

.message-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    position: relative;
    animation: messageSlide 0.3s ease-out;
    overflow: hidden;
    word-break: break-word;
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-bubble.user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-bubble.ai {
    background: var(--bg-input);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    margin-right: auto;
}

.message-content {
    font-size: 0.9rem;
    line-height: 1.6;
    word-break: break-word;
}

.message-image {
    max-width: 160px;
    max-height: 160px;
    width: auto;
    height: auto;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    display: block;
    object-fit: contain;
}

.message-content ul { padding-left: 1.25rem; margin: 0.5rem 0; }

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
}

[data-theme="dark"] .message-content code { background: rgba(255, 255, 255, 0.1); }

.message-content pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 0.5rem 0;
    font-size: 0.85rem;
}

.message-content pre code { background: none; padding: 0; }

.message-content img {
    max-width: 160px;
    max-height: 160px;
    border-radius: var(--radius-sm);
    margin: 0.5rem 0;
    cursor: pointer;
    transition: transform var(--transition);
    object-fit: contain;
}

.message-content img:hover { transform: scale(1.05); }

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-align: right;
}

/* 消息分区指示器 */
.message-divider {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.5rem;
    opacity: 0.7;
}

/* 表情图片网格 */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.emoji-grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

/* 输入区域 */
.input-container {
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem;
    background: var(--bg-card);
}

.input-actions {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.btn-action {
    background: none;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all var(--transition);
    color: var(--text-secondary);
}

.btn-action:hover { background: var(--bg-input); color: var(--text); }
.btn-action.active { background: rgba(79, 70, 229, 0.1); color: var(--primary); }

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    transition: all var(--transition);
    border: 2px solid transparent;
}

.input-wrapper:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.5;
}

#messageInput::placeholder { color: var(--text-muted); }

.send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
}

.send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.08);
}

.send-btn:active { transform: scale(0.92); }

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.send-icon { font-size: 1rem; }

.send-wave {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    animation: sendWave 2s ease-out infinite;
    border: 2px solid var(--primary);
}

@keyframes sendWave {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.4rem;
    padding: 0 0.25rem;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
    opacity: 0;
    transition: opacity var(--transition);
}

.typing-indicator.active { opacity: 1; }

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.token-counter { font-size: 0.7rem; color: var(--text-muted); }

/* ==================== 预设词提取 ==================== */
.extract-container {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.5s ease;
}

.extract-header {
    text-align: center;
    padding: 1rem 0;
}

.extract-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.extract-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.input-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
    box-shadow: var(--shadow);
}

.input-card:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px var(--primary-glow), var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 600;
}

#extractTextarea {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    padding: 1rem;
    resize: vertical;
    outline: none;
    line-height: 1.6;
    min-height: 160px;
}

#extractTextarea::placeholder { color: var(--text-muted); }

.input-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    transition: color var(--transition);
}

.btn-clear:hover { color: var(--text); }

.extract-btn {
    width: 100%;
    padding: 0.85rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.extract-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.3);
}

.extract-btn:active:not(:disabled) { transform: translateY(0) scale(0.98); }

.extract-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-spinner { display: none; gap: 4px; align-items: center; }

.extract-btn.loading .btn-text { display: none; }
.extract-btn.loading .btn-spinner { display: flex; }

.btn-spinner .spinner-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: white;
    animation: spinBounce 1s ease-in-out infinite;
}

.btn-spinner .spinner-dot:nth-child(2) { animation-delay: 0.15s; }
.btn-spinner .spinner-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes spinBounce {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-6px); opacity: 1; }
}

.btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    pointer-events: none;
}

.extract-results-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.results-header h3 { font-size: 0.9rem; font-weight: 600; }

.results-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
}

.results-grid { padding: 1rem; min-height: 100px; }

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

.empty-hint { font-size: 0.8rem; opacity: 0.6; }

.result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    animation: slideInRight 0.3s ease forwards;
    opacity: 0;
    transition: all var(--transition);
}

.result-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.result-text {
    font-size: 0.9rem;
    color: var(--text);
    flex: 1;
}

.result-send {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.result-send:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* ==================== 设置面板 ==================== */
.settings-panel, .memory-panel {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.settings-panel.open, .memory-panel.open { display: flex; }

.settings-overlay, .memory-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.settings-content, .memory-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.settings-header, .memory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.settings-header h2, .memory-header h2 { font-size: 1.1rem; font-weight: 600; }

.close-btn {
    background: var(--bg-input);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.close-btn:hover { background: var(--border); color: var(--text); }
.close-btn:active { transform: scale(0.9); }

.settings-body, .memory-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-group { display: flex; flex-direction: column; gap: 0.5rem; }

.setting-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.setting-group input[type="text"],
.setting-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: all var(--transition);
}

.setting-group input:focus, .setting-group textarea:focus {
    border-color: var(--primary-light);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.setting-group select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}

.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.toggle {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--border);
    border-radius: 13px;
    cursor: pointer;
    transition: all var(--transition);
}

.toggle.active { background: var(--primary); }

.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.toggle.active::after { left: 25px; }

.btn-primary, .btn-secondary {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
}

.btn-secondary:hover { background: var(--border); }

/* ==================== Toast 通知 ==================== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 1rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    color: var(--text);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    max-width: 350px;
}

.toast.out { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

.toast.success { border-left: 3px solid #22C55E; }
.toast.error { border-left: 3px solid #EF4444; }
.toast.info { border-left: 3px solid var(--primary); }

/* ==================== 微信弹窗 ==================== */
.wechat-modal {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.wechat-modal.open { display: flex; }

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-body {
    padding: 1rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ==================== 记忆面板 ==================== */
.memory-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    gap: 0.75rem;
    transition: all var(--transition);
}

.memory-item:hover { background: var(--border); }

.memory-text { flex: 1; font-size: 0.85rem; color: var(--text); line-height: 1.5; }

.memory-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px;
    transition: color var(--transition);
    flex-shrink: 0;
}

.memory-delete:hover { color: #EF4444; }

.memory-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.memory-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .main-content {
        padding: 70px 1rem 1.5rem;
        max-width: 100%;
    }

    .nav-container {
        padding: 0 0.75rem;
        height: 52px;
    }

    .nav-menu {
        position: fixed;
        top: 52px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
        padding: 0.5rem;
        gap: 0;
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: var(--shadow-lg);
    }

    .nav-menu.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .nav-item { width: 100%; padding: 0.75rem 1rem; }

    .menu-toggle { display: flex; }
    .theme-toggle { margin-left: auto; }
    .menu-toggle.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
    .menu-toggle.open span:nth-child(2) { opacity: 0; }
    .menu-toggle.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

    .contacts-grid {
        grid-template-columns: 1fr;
    }

    .blog-placeholder {
        grid-template-columns: 1fr;
    }

    .chat-container { height: calc(100vh - 120px); border-radius: 0; border: none; }

    .message-bubble { max-width: 92%; padding: 0.6rem 0.8rem; }

    .message-content { font-size: 0.88rem; }

    .message-image { max-width: 140px; max-height: 140px; }

    .message-content img { max-width: 140px; max-height: 140px; }

    .input-container { padding: 0.5rem 0.6rem; }

    .input-actions { gap: 0.2rem; }

    .btn-action { width: 28px; height: 28px; font-size: 0.8rem; }

    #messageInput { font-size: 0.85rem; }

    .send-btn { width: 30px; height: 30px; }

    .motto { font-size: 1.5rem; }

    /* 角色扮演移动端 */
    .extract-form {
        flex-direction: column;
        gap: 0.75rem;
    }
    .extract-sep {
        align-self: center;
    }
    .extract-input {
        width: 100%;
    }
    .extract-container {
        padding: 1rem;
    }
    .role-header {
        padding: 1rem;
        gap: 0.5rem;
    }
    .role-prompt {
        padding: 1rem;
        max-height: 250px;
    }
    .role-actions {
        flex-direction: column;
        padding: 0.75rem 1rem;
    }
    .extract-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .nav-text { display: none; }
    .nav-item { justify-content: center; }

    .message-bubble { max-width: 95%; }

    .extract-header h2 { font-size: 1.4rem; }

    .settings-content, .memory-content {
        width: 100%;
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 90vh;
        margin-top: 10vh;
    }

    /* 小屏角色扮演 */
    .extract-form {
        flex-direction: column;
        gap: 0.5rem;
    }
    .extract-sep {
        display: none;
    }
    .extract-input {
        font-size: 0.9rem;
        padding: 0.6rem 0.8rem;
    }
    .extract-btn {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    .role-play-card {
        margin: 0.5rem 0;
    }
    .role-prompt pre {
        font-size: 0.8rem;
        padding: 0.75rem;
    }
}

/* 头像选择器 */
.avatar-picker {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.avatar-picker.show {
    opacity: 1;
    pointer-events: auto;
}
.picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.picker-header h3 {
    margin: 0;
    font-size: 1.2rem;
}
.picker-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
}
.picker-close:hover {
    color: var(--text);
}
.picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}
.avatar-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
}
.avatar-option:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}
.avatar-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}
.option-emoji {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    transition: transform var(--transition);
}
.avatar-option:hover .option-emoji {
    transform: scale(1.1);
}
.option-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

/* 角色扮演卡片 */
.role-play-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: fadeInUp 0.5s ease;
}
.role-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
}
.role-icon {
    font-size: 1.5rem;
}
.role-name {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text);
}
.role-prompt {
    padding: 1.5rem;
    max-height: 300px;
    overflow-y: auto;
}
.role-prompt pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-input);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
.role-actions {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-hover);
}
.role-actions .result-send,
.role-actions .btn-secondary {
    flex: 1;
    justify-content: center;
}

/* 提取表单 */
.extract-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.extract-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.95rem;
    transition: all var(--transition);
}
.extract-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.extract-sep {
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-width: 1rem;
    text-align: center;
}

/* AI 头像可点击 */
.ai-avatar {
    cursor: pointer;
    transition: transform var(--transition);
    position: relative;
}
.ai-avatar:hover {
    transform: scale(1.05);
}
.ai-avatar::after {
    content: '🔄';
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--primary);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}
.ai-avatar:hover::after {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}