:root {
    --purple-dark: #c45c3e;
    --purple-light: #5a7d6a;
    --pink: #a84832;
    --bg: #faf6f1;
    --bg-warm: #f0e9df;
    --card: #fffdf9;
    --text: #2c2420;
    --text-secondary: #7a6f66;
    --text-muted: #a09488;
    --primary: #c45c3e;
    --accent: #5a7d6a;
    --accent-light: #e8f0eb;
    --accent-gradient: linear-gradient(135deg, #c45c3e, #a84832);
    --wechat: #07C160;
    --border: #e8dfd4;
    --shadow-sm: 0 2px 8px rgba(44,36,32,0.04);
    --shadow: 0 4px 20px rgba(44,36,32,0.06);
    --shadow-lg: 0 8px 32px rgba(44,36,32,0.08);
    --radius-xl: 20px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --tabbar-h: 56px;
    --font: 'Manrope', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; border: none; background: none; cursor: pointer; }
img { display: block; max-width: 100%; }

.page-wrap {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
}

.has-tabbar { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); }
.has-fab { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 72px); }

/* ===== Top Bar ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: rgba(250,246,241,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-title {
    font-size: 17px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.topbar-back {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--card);
    box-shadow: var(--shadow-sm);
}
.topbar-back svg { width: 18px; height: 18px; }
.topbar-right { min-width: 36px; text-align: right; }

.badge-token {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, var(--purple-dark), var(--purple-light));
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 20px;
}
.badge-token svg { width: 12px; height: 12px; }
.chat-header-avatar {
    width: 40px; height: 40px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

/* ===== Cards ===== */
.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 20px 10px;
}

/* ===== Activity Banners ===== */
.activity-list { padding: 0 16px 8px; }
.activity-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.15s;
    border-left: 3px solid var(--pink);
    position: relative;
    overflow: hidden;
}
.activity-banner:active { transform: scale(0.98); }
.activity-banner::after {
    content: '›';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--text-muted);
    font-weight: 300;
}
.activity-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--accent-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.activity-text { flex: 1; padding-right: 20px; }
.activity-text .act-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--pink);
    line-height: 1.3;
}
.activity-text .act-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Agent Cards ===== */
.agent-list { padding: 0 16px; }
.agent-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    position: relative;
}
.agent-card:active { transform: scale(0.98); }
.agent-card.is-active {
    border-color: var(--purple-dark);
    box-shadow: var(--shadow-lg);
}
.agent-card.is-frozen {
    opacity: 0.55;
    filter: grayscale(0.4);
}
.agent-card.is-frozen::after {
    content: '点击激活';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 12px;
}
.agent-avatar {
    width: 52px; height: 52px;
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.agent-info { flex: 1; min-width: 0; }
.agent-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.agent-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.status-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 8px;
    flex-shrink: 0;
}
.status-tag.active { background: linear-gradient(135deg, var(--purple-dark), var(--purple-light)); color: #fff; }
.status-tag.frozen { background: #E5E5EA; color: var(--text-muted); }

/* ===== FAB Create Button ===== */
.fab-bar {
    position: fixed;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    padding: 0 20px;
    z-index: 90;
}
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 15px;
    border-radius: 28px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.15s;
    border: none;
    cursor: pointer;
}
.btn:active { transform: scale(0.97); opacity: 0.9; }
.btn-primary { background: linear-gradient(135deg, var(--purple-dark), var(--purple-light)); color: #fff; box-shadow: 0 4px 16px rgba(108,60,225,0.3); }
.btn-secondary { background: var(--card); color: var(--purple-dark); border: 1.5px solid var(--purple-dark); }
.btn-wechat { background: var(--wechat); color: #fff; box-shadow: 0 4px 16px rgba(7,193,96,0.3); }
.btn-accent { background: linear-gradient(135deg, var(--pink), #FF8FB1); color: #fff; box-shadow: 0 4px 16px rgba(255,107,157,0.3); }
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 20px; width: auto; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

/* ===== Tab Bar ===== */
.tabbar {
    position: fixed;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 200;
}
.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    transition: color 0.2s;
}
.tab-item svg { width: 22px; height: 22px; }
.tab-item.active { color: var(--purple-dark); font-weight: 600; }

/* ===== Login Page ===== */
/* ===== Login Page (match landing hero) ===== */
.page-login {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.page-login::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(167,139,250,0.3) 0%, transparent 65%);
    top: -120px; right: -80px;
    pointer-events: none;
}
.page-login::after {
    content: '';
    position: absolute;
    width: 350px; height: 350px;
    background: radial-gradient(circle, rgba(129,140,248,0.2) 0%, transparent 65%);
    bottom: -80px; left: -60px;
    pointer-events: none;
}
.login-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
}
.login-brand {
    width: 80px; height: 80px;
    background: var(--accent-gradient);
    border-radius: 24px;
    margin: 0 auto 24px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 32px rgba(244,63,94,0.35);
}
.login-brand svg { width: 44px; height: 44px; color: #fff; }
.login-title {
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 8px;
}
.login-subtitle {
    font-size: 15px;
    color: rgba(255,255,255,0.85);
    line-height: 1.6;
    margin-bottom: 40px;
}
.login-features {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 40px;
}
.login-feat { text-align: center; }
.login-feat-icon { font-size: 24px; margin-bottom: 6px; }
.login-feat-text { font-size: 11px; color: rgba(255,255,255,0.7); }
.login-btns { display: flex; flex-direction: column; gap: 12px; }
.login-btns .btn { max-width: 320px; margin: 0 auto; }
.login-title { color: var(--text); }
.login-subtitle { color: var(--text-secondary); }
.login-feat-text { color: var(--text-muted); }
.login-btns .btn-wechat {
    background: var(--wechat);
    color: #fff;
    box-shadow: 0 4px 16px rgba(7,193,96,0.3);
}
.login-btns .btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* ===== Chat Page ===== */
.page-chat { background: var(--bg); }
.chat-header {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    background: rgba(247,243,236,0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.chat-header-avatar {
    width: 40px; height: 40px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; color: #fff;
}
.chat-header-info { flex: 1; }
.chat-header-name { font-size: 16px; font-weight: 600; }
.chat-header-status { font-size: 12px; color: var(--wechat); }
.chat-messages {
    padding: 16px;
    min-height: calc(100vh - 180px);
}
.msg-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: flex-end;
}
.msg-row.user { flex-direction: row-reverse; }
.msg-avatar-sm {
    width: 32px; height: 32px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600; color: #fff;
    flex-shrink: 0;
}
.msg-bubble {
    max-width: 72%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.55;
    word-break: break-word;
}
.msg-row.assistant .msg-bubble {
    background: var(--card);
    box-shadow: var(--shadow-sm);
    border-bottom-left-radius: 4px;
}
.msg-row.user .msg-bubble {
    background: linear-gradient(135deg, var(--purple-dark), var(--purple-light));
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg-time {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin: 16px 0;
}
.typing-indicator {
    display: flex; gap: 4px; padding: 12px 16px;
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
    width: fit-content;
}
.typing-indicator span {
    width: 7px; height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.chat-input-area {
    position: fixed;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom));
    left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px;
    padding: 8px 12px;
    background: rgba(247,243,236,0.95);
    backdrop-filter: blur(12px);
    display: flex; gap: 8px; align-items: center;
    border-top: 1px solid var(--border);
}
.chat-input {
    flex: 1;
    padding: 11px 18px;
    border: 1.5px solid var(--border);
    border-radius: 24px;
    font-size: 15px;
    background: var(--card);
    outline: none;
    transition: border-color 0.2s;
}
.chat-input:focus { border-color: var(--primary); }
.chat-send-btn {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--purple-dark), var(--purple-light));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}
.chat-send-btn:active { transform: scale(0.9); }
.chat-send-btn svg { width: 20px; height: 20px; }

/* ===== Forms ===== */
.form-page { padding: 0 16px 24px; }
.form-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}
.form-group { margin-bottom: 20px; }
.form-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.form-input, .form-textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 15px;
    background: var(--bg);
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    font-family: inherit;
}
.form-input:focus, .form-textarea:focus {
    border-color: var(--primary);
    background: var(--card);
}
.form-textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
.char-count { text-align: right; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.preset-chip {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 16px;
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
}
.preset-chip:active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Recharge ===== */
.recharge-hero {
    margin: 0 16px 20px;
    padding: 24px 20px;
    background: linear-gradient(135deg, var(--purple-dark), var(--purple-light));
    border-radius: var(--radius-xl);
    color: #fff;
    position: relative;
    overflow: hidden;
}
.recharge-hero::after {
    content: '';
    position: absolute;
    width: 120px; height: 120px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    top: -30px; right: -20px;
}
.recharge-hero h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.recharge-hero p { font-size: 13px; opacity: 0.7; }
.recharge-balance {
    margin-top: 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
}
.package-grid { padding: 0 16px; }
.package-card {
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    position: relative;
}
.package-card.selected { border-color: var(--purple-dark); }
.package-card.selected::before {
    content: '✓';
    position: absolute;
    top: 12px; right: 14px;
    width: 22px; height: 22px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}
.package-icon {
    width: 48px; height: 48px;
    border-radius: 14px;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.package-info { flex: 1; }
.package-name { font-size: 16px; font-weight: 600; }
.package-tokens { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.package-price { font-size: 22px; font-weight: 800; background: linear-gradient(135deg, var(--purple-dark), var(--pink)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.package-price small { font-size: 14px; font-weight: 600; }
.package-badge {
    font-size: 10px;
    background: var(--accent-light);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 600;
    margin-left: 6px;
}
.pay-bar {
    position: fixed;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom));
    left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px;
    padding: 12px 20px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
}

/* ===== Profile ===== */
.profile-header {
    margin: 0 16px 16px;
    padding: 24px 20px;
    background: var(--card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}
.profile-avatar {
    width: 64px; height: 64px;
    border-radius: 20px;
    overflow: hidden;
    background: var(--bg-warm);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 20px; font-weight: 700; }
.profile-meta { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.menu-section { padding: 0 16px; margin-bottom: 16px; }
.menu-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0 4px 8px;
}
.menu-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.menu-item:last-child { border-bottom: none; }
.menu-item-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.menu-item-body { flex: 1; }
.menu-item-title { font-size: 15px; font-weight: 500; }
.menu-item-desc { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.menu-item-action { font-size: 13px; color: var(--accent); font-weight: 500; }
.menu-item-action.muted { color: var(--text-muted); font-weight: 400; }

/* ===== Activity Detail ===== */
.activity-hero {
    margin: 0 16px 20px;
    padding: 28px 20px;
    background: linear-gradient(135deg, var(--purple-dark), var(--pink));
    border-radius: var(--radius-xl);
    color: #fff;
}
.activity-hero h2 { font-size: 20px; font-weight: 700; line-height: 1.4; }
.activity-hero .act-expire { font-size: 12px; opacity: 0.8; margin-top: 8px; }
.activity-body {
    margin: 0 16px;
    padding: 20px;
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    line-height: 1.8;
    font-size: 15px;
    color: var(--text);
}

/* ===== Empty & Loading ===== */
.empty-state {
    text-align: center;
    padding: 60px 32px;
}
.empty-illustration {
    width: 100px; height: 100px;
    background: var(--bg-warm);
    border-radius: 50%;
    margin: 0 auto 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 40px;
}
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
}
.spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(28,28,30,0.88);
    color: #fff;
    padding: 14px 28px;
    border-radius: 14px;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s;
    backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.skeleton {
    background: linear-gradient(90deg, var(--bg) 25%, var(--bg-warm) 50%, var(--bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}
@keyframes shimmer { to { background-position: -200% 0; } }
