/* NexusLink V3 设计系统 */
/* Hybrid: Bento Grid + Warm Soft Brutalism + Variable Fonts + Micro-interactions */
/* 版本: 3.1 | 日期: 2026-05-05 | 设计方向: 温润新粗野主义 + AI透明感 */

/* ========================================
   0. Variable Font 加载
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ========================================
   1. 设计令牌 (Design Tokens)
   ======================================== */
:root {
    /* ---- 主色调：星际紫 ---- */
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-light: #a78bfa;
    --primary-dark: #6d28d9;
    --primary-glow: rgba(139, 92, 246, 0.25);
    --primary-surface: rgba(139, 92, 246, 0.08);

    /* ---- 辅助色 ---- */
    --accent-blue: #06b6d4;
    --accent-green: #10b981;
    --accent-pink: #ec4899;
    --accent-orange: #f59e0b;

    /* ---- 宝石色调 (Warm Jewel Tones → 温润新粗野主义) ---- */
    --candy-lemon: #fde68a;      /* 琥珀 — 温暖/社交 */
    --candy-pink: #f9a8d4;       /* 粉晶 — 创作/表达 */
    --candy-lavender: #c4b5fd;   /* 紫水晶 — 思考/私语 */
    --candy-mint: #a7f3d0;       /* 翡翠薄荷 — 在线/活跃 */
    --candy-sky: #93c5fd;        /* 蓝宝石 — 知识/理性 */
    --candy-peach: #fed7aa;      /* 珊瑚 — 活力/通知 */
    --candy-rose: #fda4af;       /* 玫瑰 — 重要/警示 */

    /* 向后兼容别名 */
    --candy-lime: var(--candy-mint);        /* 旧 --candy-lime → 翡翠薄荷 */
    --candy-purple: var(--candy-lavender);  /* 旧 --candy-purple → 紫水晶 */
    --candy-blue: var(--candy-sky);         /* 旧 --candy-blue → 蓝宝石 */
    --candy-orange: var(--candy-peach);     /* 旧 --candy-orange → 珊瑚 */

    /* ---- Surface Elevation 深度系统 (暗色优先) ---- */
    --surface-0: #0a0a12;
    --surface-1: #12121f;
    --surface-2: #1a1a2e;
    --surface-3: #24243a;
    --surface-4: #2e2e46;

    /* ---- 深色模式文字 ---- */
    --text-primary: #f1f0f5;
    --text-secondary: #9d9bae;
    --text-muted: #5e5c72;
    --text-inverse: #0a0a12;

    /* ---- 边框系统 (Warm Soft Brutalism: 软化边框) ---- */
    --border-thin: 1.5px solid var(--text-muted);
    --border-normal: 2px solid var(--text-muted);
    --border-bold: 3px solid var(--text-inverse);
    --border-accent: 2px solid var(--primary);
    --border-neo: 2px solid #000;

    /* ---- 阴影系统 (软化阴影: 小模糊+低透明度) ---- */
    --shadow-neo-sm: 3px 3px 0px rgba(0,0,0,0.25);
    --shadow-neo: 5px 5px 0px rgba(0,0,0,0.25);
    --shadow-neo-lg: 8px 8px 0px rgba(0,0,0,0.25);
    --shadow-neo-hover: 6px 6px 0px rgba(0,0,0,0.3);
    --shadow-neo-accent: 5px 5px 0px var(--primary);
    --shadow-neo-blue: 5px 5px 0px var(--accent-blue);
    --shadow-glow: 0 0 20px var(--primary-glow);

    /* 圆角 */
    --radius-none: 0px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --radius-blob: 30% 70% 70% 30% / 30% 30% 70% 70%;

    /* 间距 Scale (4px base) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;

    /* 向后兼容: --spacing-* → --sp-* 映射 */
    --spacing-xs: var(--sp-1);
    --spacing-sm: var(--sp-2);
    --spacing-md: var(--sp-4);
    --spacing-lg: var(--sp-6);
    --spacing-xl: var(--sp-8);
    --spacing-2xl: var(--sp-10);
    --spacing-3xl: var(--sp-12);

    /* 动画时长 Token */
    --dur-instant: 100ms;
    --dur-fast: 150ms;
    --dur-base: 250ms;
    --dur-slow: 400ms;
    --dur-reveal: 600ms;

    /* 缓动曲线 */
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);

    /* 组合过渡 (向后兼容) */
    --transition-fast: var(--dur-fast) var(--ease-smooth);
    --transition-base: var(--dur-base) var(--ease-smooth);
    --dur-spring: 350ms var(--ease-spring);

    /* 字体 */
    --font-display: 'Space Grotesk', system-ui, sans-serif;
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* ---- Type Scale (Semantic 字号 Token) ---- */
    --text-2xs: 0.625rem;   /* 10px — 极微小标签 */
    --text-xs: 0.75rem;      /* 12px — 辅助文字 */
    --text-sm: 0.8125rem;    /* 13px — 小号正文 */
    --text-base: 0.9375rem;  /* 15px — 正文 */
    --text-md: 1.0625rem;    /* 17px — 强调正文 */
    --text-lg: 1.25rem;      /* 20px — 小节标题 */
    --text-xl: 1.5rem;       /* 24px — 页面标题 */
    --text-2xl: 1.875rem;    /* 30px — 大标题 */
    --text-3xl: 2.25rem;     /* 36px — Hero 标题 */

    /* 实体配色 */
    --human-color: #10b981;
    --human-bg: rgba(16, 185, 129, 0.12);
    --human-border: 2px solid #10b981;
    --digital-color: #8b5cf6;
    --digital-bg: rgba(139, 92, 246, 0.12);
    --digital-border: 2px solid #8b5cf6;
    --agent-color: #06b6d4;
    --agent-bg: rgba(6, 182, 212, 0.12);
    --agent-border: 2px solid #06b6d4;
    --system-color: #f59e0b;
    --system-bg: rgba(245, 158, 11, 0.12);
    --system-border: 2px solid #f59e0b;

    /* 状态色 */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* 页面容器最大宽度 */
    --page-max-width: 960px;
}

/* ========================================
   2. 浅色模式覆盖
   ======================================== */
[data-theme="light"] {
    --surface-0: #faf8ff;
    --surface-1: #f3f0ff;
    --surface-2: #ebe6ff;
    --surface-3: #e2dcff;
    --surface-4: #d9d2ff;

    --text-primary: #1a1a2e;
    --text-secondary: #5e5c72;
    --text-muted: #9d9bae;
    --text-inverse: #ffffff;

    --shadow-neo-sm: 3px 3px 0px rgba(0,0,0,0.12);
    --shadow-neo: 5px 5px 0px rgba(0,0,0,0.12);
    --shadow-neo-lg: 8px 8px 0px rgba(0,0,0,0.12);
    --shadow-neo-hover: 6px 6px 0px rgba(0,0,0,0.18);
    --shadow-neo-accent: 5px 5px 0px var(--primary);
    --shadow-neo-blue: 5px 5px 0px var(--accent-blue);

    --border-thin: 1.5px solid var(--text-muted);
    --border-normal: 2px solid var(--text-muted);
    --border-bold: 3px solid var(--text-primary);
    --border-neo: 2px solid rgba(0,0,0,0.15);

    /* 浅色下宝石色提亮 */
    --candy-lemon: #fef3c7;
    --candy-pink: #fce7f3;
    --candy-lavender: #e8dff5;
    --candy-mint: #d4fcd0;
    --candy-sky: #dbeafe;
    --candy-peach: #ffedd5;
    --candy-rose: #ffe4e6;
}

/* ========================================
   3. 基础重置
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--font-sans);
    background: var(--surface-0);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- 背景纹理 (点阵图案) ---- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, var(--text-muted) 0.5px, transparent 0.5px);
    background-size: 24px 24px;
    opacity: 0.06;
    pointer-events: none;
    z-index: 0;
}

/* ========================================
   4. 排版系统 (Editorial Style)
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.display-xl {
    font-family: var(--font-display);
    font-size: clamp(32px, 6vw, 56px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.display-lg {
    font-family: var(--font-display);
    font-size: clamp(24px, 4vw, 40px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.display-md {
    font-family: var(--font-display);
    font-size: clamp(20px, 3vw, 28px);
    font-weight: 600;
    letter-spacing: -0.015em;
}

.text-label {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.text-mono {
    font-family: var(--font-mono);
    font-size: 13px;
}

/* ========================================
   5. Bento Grid 布局系统
   ======================================== */
.bento-grid {
    display: grid;
    gap: var(--sp-3);
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(100px, auto);
}

/* 标准Bento区域命名 */
.bento-hero { grid-column: 1 / -1; }
.bento-wide { grid-column: span 2; }
.bento-tall { grid-row: span 2; }
.bento-featured { grid-column: span 2; grid-row: span 2; }

/* 预设布局模板 */
.bento-layout-home {
    grid-template-columns: repeat(4, 1fr);
    grid-template-areas:
        "hero   hero   hero   hero"
        "chat   chat   community  knowledge"
        "chat   chat   community  market"
        "plaza  endeavors dao   skills"
        "feed   feed   feed   feed";
    grid-template-rows:
        auto
        minmax(50px, auto)
        minmax(40px, auto)
        minmax(60px, auto)
        auto;
}

/* ========================================
   6. 统一页面容器
   ======================================== */
.page-container {
    max-width: var(--page-max-width, 960px);
    margin: 0 auto;
    padding: var(--sp-3);
}
.page-container--wide { --page-max-width: 1200px; }
.page-container--narrow { --page-max-width: 680px; }
.page-container--full { --page-max-width: 100%; }

/* ========================================
   7. 卡片组件 (Warm Soft Brutalism)
   ======================================== */

/* ---- 基础卡片 ---- */
.neo-card {
    background: var(--surface-1);
    border: var(--border-neo);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-neo);
    padding: var(--sp-4);
    transition: transform var(--dur-spring),
                box-shadow var(--dur-spring);
    position: relative;
    overflow: hidden;
}

.neo-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-neo-hover);
}

.neo-card:active {
    transform: translate(2px, 2px);
    box-shadow: var(--shadow-neo-sm);
}

/* ---- 宝石色卡片变体 ---- */
.neo-card.candy-lemon { background: var(--candy-lemon); }
.neo-card.candy-pink { background: var(--candy-pink); }
.neo-card.candy-lavender { background: var(--candy-lavender); }
.neo-card.candy-mint { background: var(--candy-mint); }
.neo-card.candy-sky { background: var(--candy-sky); }
.neo-card.candy-peach { background: var(--candy-peach); }

/* ---- Surface 卡片 (更柔和的深度) ---- */
.surface-card {
    background: var(--surface-2);
    border: 1px solid var(--surface-4);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    transition: all var(--transition-base);
}

.surface-card:hover {
    background: var(--surface-3);
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* ---- Glassmorphism 2.0 (毛玻璃) ---- */
.glass-card {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: var(--sp-3);
    transition: all var(--transition-base);
}

[data-theme="light"] .glass-card {
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* ========================================
   8. 按钮系统 (Warm Soft Brutalism)
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 10px 20px;
    border: var(--border-neo);
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--dur-spring),
                box-shadow var(--dur-spring);
    position: relative;
    text-decoration: none;
    min-height: 42px;
    line-height: 1;
}

.btn:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #000 !important;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-neo-hover);
}

.btn-secondary {
    background: var(--candy-lavender);
    color: var(--primary-dark);
    box-shadow: var(--shadow-neo);
}

.btn-secondary:hover:not(:disabled) {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-neo-hover);
}

.btn-ghost {
    background: transparent;
    border-color: var(--surface-4);
    color: var(--text-primary);
    box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-2);
    transform: translate(-1px, -1px);
    box-shadow: var(--shadow-neo-sm);
}

.btn-danger {
    background: var(--candy-rose);
    color: #b91c1c;
    border-color: #000;
    box-shadow: var(--shadow-neo);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    min-height: 32px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    min-height: 48px;
}

.btn-icon {
    padding: 10px;
    min-width: 42px;
    min-height: 42px;
}

.btn-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn svg {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-accent {
    background: var(--candy-mint);
    color: #065f46;
    box-shadow: var(--shadow-neo);
}

.btn-accent:hover:not(:disabled) {
    transform: translate(-2px, -2px);
    box-shadow: var(--shadow-neo-hover);
}

/* ========================================
   9. 实体徽章
   ======================================== */
.entity-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 2px solid;
}

.entity-badge.human {
    background: var(--human-bg);
    color: var(--human-color);
    border-color: var(--human-color);
}

.entity-badge.digital {
    background: var(--digital-bg);
    color: var(--digital-color);
    border-color: var(--digital-color);
}

.entity-badge.agent {
    background: var(--agent-bg);
    color: var(--agent-color);
    border-color: var(--agent-color);
}

.entity-badge.system {
    background: var(--system-bg);
    color: var(--system-color);
    border-color: var(--system-color);
}

/* ========================================
   10. 导航栏 (Sticky + Glassmorphism)
   ======================================== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-4);
    background: rgba(18, 18, 31, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 54px;
}

[data-theme="light"] .navbar {
    background: rgba(243, 240, 255, 0.9);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.navbar-brand .brand-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-neo-sm);
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    list-style: none;
}

.navbar-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 13px;
    transition: all var(--transition-fast);
}

.navbar-nav a:hover,
.navbar-nav a.active {
    color: var(--primary);
    background: var(--primary-surface);
}

/* ========================================
   11. 输入框
   ======================================== */
.input {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-1);
    border: var(--border-thin);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 3px 3px 0px var(--primary);
}

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

.input-group {
    position: relative;
}

.input-group .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
}

.input-group .input {
    padding-left: 38px;
}

/* ========================================
   12. 头像系统
   ======================================== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    object-fit: cover;
    border: var(--border-neo);
    box-shadow: var(--shadow-neo-sm);
}

.avatar-sm { width: 32px; height: 32px; }
.avatar-lg { width: 52px; height: 52px; }
.avatar-xl { width: 72px; height: 72px; }

.avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: var(--border-neo);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: white;
}

/* ========================================
   13. 消息气泡
   ======================================== */
.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    margin: 4px 0;
    position: relative;
    word-wrap: break-word;
    border: var(--border-thin);
}

.message-bubble.sent,
.message-bubble.message-mine {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
    border-bottom-right-radius: 2px;
    margin-left: auto;
    box-shadow: var(--shadow-neo-sm);
}

.message-bubble.received,
.message-bubble.message-other {
    background: var(--surface-2);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
    box-shadow: var(--shadow-neo-sm);
}

/* ========================================
   14. 动画系统 (Micro-interactions)
   ======================================== */

/* ---- Stagger 入场动画 ---- */
.stagger-in > * {
    opacity: 0;
    transform: translateY(16px);
    animation: staggerUp var(--dur-slow) var(--ease-out) forwards;
}
.stagger-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-in > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-in > *:nth-child(8) { animation-delay: 0.4s; }

@keyframes staggerUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- 页面过渡 ---- */
.page-transition {
    animation: pageSlideIn 0.4s var(--ease-out);
}

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

/* ---- 卡片入场 ---- */
.card-enter {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    animation: cardPop 0.4s var(--ease-spring) forwards;
}

@keyframes cardPop {
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---- 消息入场 ---- */
.message-enter {
    animation: messageSlide 0.3s var(--ease-spring);
}

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

/* ---- 骨架屏 (Shimmer) ---- */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- 加载圆点 ---- */
.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    animation: dotBounce 1.2s infinite ease-in-out;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ---- 脉冲呼吸动画 (在线状态) ---- */
.pulse-ring {
    position: relative;
}
.pulse-ring::before {
    content: '';
    position: absolute;
    top: -3px; left: -3px; right: -3px; bottom: -3px;
    border-radius: 50%;
    border: 2px solid var(--success);
    animation: pulseRing 2s ease-out infinite;
}

@keyframes pulseRing {
    0% { opacity: 0.6; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.4); }
}

/* ---- 主题切换过渡 ---- */
.theme-transitioning,
.theme-transitioning * {
    transition: background-color 0.4s ease,
                color 0.3s ease,
                border-color 0.3s ease,
                box-shadow 0.3s ease !important;
}

/* ---- 旋转动画 (spinner) ---- */
@keyframes iconSpin {
    to { transform: rotate(360deg); }
}

.icon svg[style*="spin"] {
    animation: iconSpin 1s linear infinite;
}

/* ========================================
   15. 状态徽章
   ======================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-display);
    border: var(--border-thin);
}

.status-badge.online {
    background: var(--human-bg);
    color: var(--success);
    border-color: var(--success);
}

.status-badge.offline {
    background: var(--surface-2);
    color: var(--text-muted);
}

.status-badge.away {
    background: var(--system-bg);
    color: var(--warning);
    border-color: var(--warning);
}

/* ========================================
   16. Toast 通知
   ======================================== */
.toast-container {
    position: fixed;
    top: 68px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 10px 16px;
    background: var(--surface-2);
    border: var(--border-neo);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-neo);
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 13px;
    animation: toastIn 0.3s var(--ease-spring);
    max-width: 320px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success { border-left: 4px solid var(--success); background: var(--candy-mint); }
.toast.error { border-left: 4px solid var(--error); background: var(--candy-rose); }
.toast.warning { border-left: 4px solid var(--warning); background: var(--candy-peach); }
.toast.info { border-left: 4px solid var(--info); background: var(--candy-sky); }

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

.toast.removing {
    animation: toastOut 0.25s var(--ease-smooth) forwards;
}

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

/* ========================================
   17. 模态框
   ======================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--surface-1);
    border: var(--border-neo);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-neo-lg);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalSlideUp 0.35s var(--ease-spring);
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: var(--border-thin);
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
}

.modal-body { padding: var(--sp-5); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-5);
    border-top: var(--border-thin);
}

/* ========================================
   18. 空状态
   ======================================== */
.empty-state {
    text-align: center;
    padding: var(--sp-10) var(--sp-5);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 56px;
    margin-bottom: var(--sp-4);
    opacity: 0.5;
}

.empty-state-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
}

/* ========================================
   19. 表单
   ======================================== */
.form-group { margin-bottom: var(--sp-4); }

.form-label {
    display: block;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: var(--sp-1);
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-1);
    border: var(--border-thin);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 3px 3px 0px var(--primary);
}

/* ========================================
   20. 成员列表/选择
   ======================================== */
.member-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--dur-fast);
}

.member-item:hover {
    background: var(--surface-2);
}

.member-name {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 500;
}

.member-type {
    font-size: 12px;
    color: var(--text-muted);
}

.member-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ========================================
   21. 通知徽章
   ======================================== */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    background: var(--error);
    color: white;
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    border-radius: var(--radius-full);
    border: 2px solid var(--surface-1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ========================================
   22. SVG 图标基础样式
   ======================================== */
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* 防御规则: 标题内的裸 SVG 图标 */
h1 > svg, h2 > svg, h3 > svg, h4 > svg, h5 > svg, h6 > svg {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
}

.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }

/* ========================================
   23. 移动端底部导航 (Glassmorphism)
   ======================================== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: var(--sp-1) 0 env(safe-area-inset-bottom, 0);
    z-index: 1000;
}

[data-theme="light"] .mobile-bottom-nav {
    background: rgba(255, 255, 255, 0.88);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.mobile-bottom-nav .nav-items {
    display: flex;
    justify-content: space-around;
}

.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    transition: color var(--transition-fast);
    border-radius: var(--radius-sm);
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
}

.mobile-bottom-nav .nav-item.active,
.mobile-bottom-nav .nav-item:hover {
    color: var(--primary);
    background: var(--primary-surface);
}

.mobile-bottom-nav .nav-item .nav-icon {
    width: 22px;
    height: 22px;
}

/* ========================================
   24. 响应式布局
   ======================================== */
@media (max-width: 1024px) {
    .mobile-bottom-nav {
        display: block;
    }

    .navbar-nav {
        display: none;
    }

    main.container {
        padding-bottom: 72px;
    }
}

@media (max-width: 640px) {
    .bento-grid,
    .bento-layout-home {
        grid-template-columns: repeat(2, 1fr);
        grid-template-areas:
            "hero  hero"
            "chat  chat"
            "community  community"
            "knowledge  market"
            "plaza  endeavors"
            "dao    skills"
            "feed  feed";
    }

    .bento-hero { grid-column: 1 / -1; }
    .bento-wide { grid-column: span 2; }
    .bento-tall { grid-row: span 1; }
    .bento-featured { grid-column: span 2; grid-row: span 1; }

    main.container {
        padding-bottom: 72px;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .bento-layout-home {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1025px) {
    .container {
        width: 95%;
        max-width: 1200px;
        margin: 0 auto;
        padding: var(--sp-3);
    }
}

/* ========================================
   25. 辅助类
   ======================================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

.hidden { display: none; }
.visible { display: block; }

.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }

.p-3 { padding: var(--sp-3); }
.p-4 { padding: var(--sp-4); }
.p-5 { padding: var(--sp-5); }

.rounded { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* 数字大字 */
.big-number {
    font-family: var(--font-display);
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

/* 活动标签 */
.activity-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-display);
    border-radius: var(--radius-sm);
    border: 1.5px solid;
}

/* ========================================
   26. Agent 状态可视化动画
   设计理念: 每个状态有独特的视觉语言，让 AI 行为透明可感知
   ======================================== */

/* Agent 状态指示点 */
.agent-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    flex-shrink: 0;
}

/* 思考中 — 紫水晶脉冲 */
.agent-status-dot.thinking {
    background: var(--candy-lavender);
    animation: agentThinking 1.5s ease-in-out infinite;
    box-shadow: 0 0 6px rgba(139, 92, 246, 0.5);
}
@keyframes agentThinking {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* 活跃/在线 — 翡翠薄荷呼吸 */
.agent-status-dot.active {
    background: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    animation: agentActive 3s ease-in-out infinite;
}
@keyframes agentActive {
    0%, 100% { box-shadow: 0 0 4px rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.6); }
}

/* 离线/休眠 — 灰度化 */
.agent-status-dot.offline {
    background: #64748b;
}

/* 创作中 — 粉晶流彩 */
.agent-status-dot.creating {
    background: var(--candy-pink);
    animation: agentCreating 2s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(249, 168, 212, 0.5);
}
@keyframes agentCreating {
    0% { background: var(--candy-pink); box-shadow: 0 0 6px rgba(249, 168, 212, 0.4); }
    33% { background: var(--candy-rose); box-shadow: 0 0 10px rgba(253, 164, 175, 0.6); }
    66% { background: var(--candy-peach); box-shadow: 0 0 8px rgba(254, 215, 170, 0.5); }
    100% { background: var(--candy-pink); box-shadow: 0 0 6px rgba(249, 168, 212, 0.4); }
}

/* 学习中 — 蓝宝石扫描线 */
.agent-status-dot.learning {
    background: var(--candy-sky);
    position: relative;
    overflow: hidden;
    animation: agentLearning 2.5s ease-in-out infinite;
}
.agent-status-dot.learning::after {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: learningScan 2.5s ease-in-out infinite;
}
@keyframes agentLearning {
    0%, 100% { box-shadow: 0 0 4px rgba(147, 197, 253, 0.4); }
    50% { box-shadow: 0 0 12px rgba(147, 197, 253, 0.7); }
}
@keyframes learningScan {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Agent 状态文本标签 */
.agent-status-label {
    font-size: var(--text-xs);
    font-family: var(--font-display);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ========================================
   27. 流式消息动画 (Agent Streaming)
   ======================================== */

.message-bubble.agent-streaming {
    position: relative;
    overflow: hidden;
}

/* 流式光晕 — 底部扫描线 */
.message-bubble.agent-streaming::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--candy-lavender), transparent);
    animation: streamShimmer 1.5s ease-in-out infinite;
}
@keyframes streamShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* 打字光标 */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--primary);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: cursorBlink 0.7s step-end infinite;
}
@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ========================================
   28. 全局微交互动效
   ======================================== */

/* 点赞脉冲 — 心形放大回弹 */
.like-pulse {
    animation: likePulse 0.45s var(--ease-spring);
}
@keyframes likePulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.4); }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* 通知铃铛摇摆 */
.notification-bell-swing {
    animation: bellSwing 0.5s var(--ease-spring);
}
@keyframes bellSwing {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    50% { transform: rotate(12deg); }
    75% { transform: rotate(-6deg); }
    100% { transform: rotate(0deg); }
}

/* 页面区块入场 */
.page-enter {
    animation: pageEnter var(--dur-reveal) var(--ease-out);
}
@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Toast 入场/退场 */
.toast-enter {
    animation: toastSlideIn var(--dur-slow) var(--ease-out);
}
.toast-exit {
    animation: toastSlideOut var(--dur-fast) var(--ease-in) forwards;
}
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(-16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastSlideOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-16px); }
}

/* Modal 入场 */
.modal-enter {
    animation: modalEnter var(--dur-base) var(--ease-out);
}
.modal-enter .modal-content {
    animation: modalContentEnter var(--dur-base) var(--ease-spring);
}
@keyframes modalEnter {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes modalContentEnter {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* FAB 悬浮按钮 */
.fab-hover {
    transition: transform var(--dur-fast) var(--ease-spring),
                box-shadow var(--dur-fast) var(--ease-smooth);
}
.fab-hover:hover {
    transform: scale(1.12);
    box-shadow: var(--shadow-glow);
}

/* 骨架加载闪烁 (sheen) */
.skeleton {
    background: linear-gradient(90deg,
        var(--surface-3) 0%,
        var(--surface-4) 40%,
        var(--surface-3) 80%
    );
    background-size: 200% 100%;
    animation: skeletonSheen 1.8s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeletonSheen {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 涟漪效果 */
@keyframes rippleEffect {
    to { transform: scale(2.5); opacity: 0; }
}

/* 通用入场延迟工具 */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }

/* ========================================
   29. 无障碍: Focus Ring
   ======================================== */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ========================================
   30. 减少动效 (prefers-reduced-motion)
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }

    .agent-status-dot.thinking,
    .agent-status-dot.active,
    .agent-status-dot.creating,
    .agent-status-dot.learning,
    .message-bubble.agent-streaming::after,
    .typing-cursor,
    .skeleton { animation: none !important; }
}

/* ========================================
   31. 隐藏移动端桌面导航 (hide-mobile)
   ======================================== */
@media (max-width: 1024px) {
    .hide-mobile {
        display: none !important;
    }
}
