/* ── Animations ─────────────────────────────────── */
@keyframes fadeInUp   { from{opacity:0;transform:translateY(24px)} to{opacity:1;transform:translateY(0)} }
@keyframes blob       { 0%,100%{transform:translate(0,0) scale(1)} 33%{transform:translate(30px,-50px) scale(1.1)} 66%{transform:translate(-20px,20px) scale(.9)} }
@keyframes skeletonPulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.animate-blob  { animation: blob 8s ease-in-out infinite; }
.animate-blob2 { animation: blob 10s ease-in-out 2s infinite; }
.fade-in-up    { animation: fadeInUp .6s ease-out both; }
.fade-in-up-d1 { animation: fadeInUp .6s .1s ease-out both; }
.fade-in-up-d2 { animation: fadeInUp .6s .2s ease-out both; }
.fade-in-up-d3 { animation: fadeInUp .6s .3s ease-out both; }
.skeleton      { animation: skeletonPulse 1.6s ease-in-out infinite; background:#e5e7eb; border-radius:.5rem; }

/* ── App card ────────────────────────────────────── */
.app-card         { transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; }
.app-card:hover   { transform: translateY(-4px); box-shadow: 0 20px 40px -8px rgba(79,70,229,.15); border-color:#c7d2fe; }
.app-card:hover .app-icon { transform: scale(1.08); }
.app-icon         { transition: transform .3s ease; }

/* ── Nav dropdown ────────────────────────────────── */
#user-menu:not(.open) #user-dropdown { display:none; }
#user-menu.open     #user-dropdown   { display:block; }

/* ── Category pills ─────────────────────────────── */
.cat-pill         { transition: all .18s ease; }
.cat-pill.active  { background:#4f46e5; color:#fff; border-color:#4f46e5; }
.cat-pill:not(.active):hover { background:#f5f3ff; color:#4f46e5; border-color:#c4b5fd; }

/* ── Orbs ────────────────────────────────────────── */
.orb { position:absolute; border-radius:9999px; filter:blur(80px); opacity:.35; pointer-events:none; }

/* ── Feature card ───────────────────────────────── */
.feature-card     { transition: transform .2s ease, box-shadow .2s ease; }
.feature-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px -4px rgba(79,70,229,.12); }

/* ── line-clamp ──────────────────────────────────── */
.line-clamp-2 { display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden; }
.line-clamp-1 { display:-webkit-box;-webkit-line-clamp:1;line-clamp:1;-webkit-box-orient:vertical;overflow:hidden; }

/* ── AI 阿云助手 (商用级) ──────────────────────── */
.ai-float-btn {
    position: fixed; bottom: 24px; right: 24px; z-index: 9998;
    display: flex; align-items: center; gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    color: #fff; border: none; border-radius: 30px;
    cursor: pointer; font-size: 15px; font-weight: 600;
    box-shadow: 0 4px 24px rgba(99,102,241,.3), 0 1px 4px rgba(0,0,0,.08);
    transition: all .3s cubic-bezier(.4,0,.2,1);
    font-family: inherit; animation: ai-float-in .5s .3s ease both;
}
@keyframes ai-float-in { from{opacity:0;transform:translateY(20px) scale(.9)} to{opacity:1;transform:translateY(0) scale(1)} }
.ai-float-btn:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 8px 32px rgba(99,102,241,.45), 0 2px 8px rgba(0,0,0,.1); }
.ai-float-btn:active { transform: scale(.95); transition: transform .1s; }
.ai-float-icon { position: relative; }
.ai-float-icon svg { width: 22px; height: 22px; }
.ai-float-label { white-space: nowrap; letter-spacing: .3px; }
.ai-float-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: #34d399; box-shadow: 0 0 8px rgba(52,211,153,.6);
    animation: ai-dot-pulse 2.5s infinite;
}
@keyframes ai-dot-pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(1.4); } }

/* Panel backdrop */
.ai-backdrop { position: fixed; inset: 0; z-index: 9998; background: rgba(15,23,42,.3); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .35s; }
.ai-backdrop.active { opacity: 1; pointer-events: auto; }

/* Panel */
.ai-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 9999;
    width: 440px; max-width: 100vw;
    background: #fff; border-left: 1px solid #e2e8f0;
    display: flex; flex-direction: column;
    transform: translateX(110%);
    transition: transform .35s cubic-bezier(.22,1,.36,1);
    box-shadow: -8px 0 48px rgba(0,0,0,.1);
}
.ai-panel.open { transform: translateX(0); }

.ai-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid #f1f5f9;
    background: linear-gradient(135deg, #faf5ff 0%, #eff6ff 100%);
    flex-shrink: 0;
}
.ai-panel-title { display: flex; align-items: center; gap: 12px; }
.ai-panel-avatar {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: #fff; box-shadow: 0 2px 8px rgba(99,102,241,.25);
}
.ai-panel-title h3 { font-size: 16px; font-weight: 700; color: #0f172a; margin: 0; line-height: 1.2; }
.ai-panel-subtitle { font-size: 11px; color: #64748b; margin: 2px 0 0; display: flex; align-items: center; gap: 4px; }
.ai-online-dot { width: 6px; height: 6px; border-radius: 50%; background: #34d399; display: inline-block; }
.ai-panel-header-actions { display: flex; gap: 2px; }
.ai-header-btn {
    width: 34px; height: 34px; border: none; background: transparent;
    border-radius: 10px; cursor: pointer; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    color: #64748b; transition: all .15s; position: relative;
}
.ai-header-btn:hover { background: #e2e8f0; color: #334155; }
.ai-header-btn:active { transform: scale(.93); }
.ai-close-btn:hover { background: #fee2e2; color: #ef4444; }

/* Suggestions — now sits inside input-area, always visible */
.ai-suggestions {
    padding: 4px 12px 6px; flex-shrink: 0;
}
.ai-suggestion-label { font-size: 11px; color: #94a3b8; display: block; margin-bottom: 6px; font-weight: 500; letter-spacing: .3px; }
.ai-suggestion-chips { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; }
.ai-chip {
    padding: 6px 8px; border-radius: 8px; border: 1px solid #e2e8f0;
    background: #fff; color: #475569; font-size: 11px; cursor: pointer;
    font-family: inherit; transition: all .18s; white-space: nowrap;
    font-weight: 500; text-align: center; overflow: hidden; text-overflow: ellipsis;
}
.ai-chip:hover { background: #ede9fe; color: #7c3aed; border-color: #c4b5fd; transform: translateY(-1px); }

/* Messages area */
.ai-messages {
    flex: 1; overflow-y: auto; padding: 16px 20px;
    display: flex; flex-direction: column; gap: 8px;
    scroll-behavior: smooth; overscroll-behavior: contain;
}
.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.ai-messages::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.ai-welcome { text-align: center; padding: 36px 16px; color: #94a3b8; }
.ai-welcome-icon { font-size: 52px; margin-bottom: 14px; filter: drop-shadow(0 4px 8px rgba(99,102,241,.15)); }
.ai-welcome h4 { font-size: 18px; color: #1e293b; margin: 0 0 8px; font-weight: 700; }
.ai-welcome p { font-size: 13px; line-height: 1.7; margin: 0; }
.ai-welcome-stats { display: flex; justify-content: center; gap: 24px; margin-top: 16px; }
.ai-welcome-stat { text-align: center; }
.ai-welcome-stat-num { font-size: 20px; font-weight: 700; color: #6366f1; }
.ai-welcome-stat-label { font-size: 10px; color: #94a3b8; margin-top: 2px; }

.ai-msg { display: flex; gap: 10px; animation: aiFadeIn .35s ease both; position: relative; }
.ai-msg:last-child { margin-bottom: 4px; }
@keyframes aiFadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.ai-msg.user { flex-direction: row-reverse; }
.ai-msg-avatar {
    width: 30px; height: 30px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; margin-top: 2px;
}
.ai-msg.assistant .ai-msg-avatar { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; }
.ai-msg.user .ai-msg-avatar { background: #cbd5e1; color: #475569; }
.ai-msg-body { flex: 1; min-width: 0; }
.ai-msg-bubble {
    display: inline-block; max-width: 82%; padding: 10px 14px; border-radius: 16px;
    font-size: 13px; line-height: 1.6; word-break: break-word;
}
.ai-msg.assistant .ai-msg-bubble { background: #f1f5f9; color: #1e293b; border-bottom-left-radius: 6px; }
.ai-msg.user .ai-msg-bubble { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; border-bottom-right-radius: 6px; }
.ai-msg-bubble p { margin: 0 0 6px; }
.ai-msg-bubble p:last-child { margin-bottom: 0; }

/* Think block — 可折叠推理面板 */
.ai-think-block {
    margin: 6px 0; border: 1px solid #e2e8f0; border-radius: 10px;
    background: #f8fafc; overflow: hidden; font-size: 12px;
}
.ai-think-summary {
    padding: 7px 12px; cursor: pointer; user-select: none;
    color: #6366f1; font-weight: 600; font-size: 12px;
    display: flex; align-items: center; gap: 6px;
    transition: background .15s;
}
.ai-think-summary:hover { background: #eef2ff; }
.ai-think-summary::before {
    content: '▶'; display: inline-block; font-size: 9px;
    transition: transform .2s; width: 12px; text-align: center;
}
.ai-think-block[open] .ai-think-summary::before {
    transform: rotate(90deg);
}
.ai-think-content {
    padding: 0 12px 10px; color: #64748b; line-height: 1.55;
    border-top: 1px solid #e2e8f0; margin: 0 12px;
    white-space: pre-wrap; word-break: break-word;
}

/* AI Panel - history sidebar */
.ai-panel-body { display: flex; flex: 1; overflow: hidden; }
.ai-history-sidebar {
    width: 0; overflow: hidden; flex-shrink: 0;
    border-right: 1px solid #e2e8f0; background: #f8fafc;
    display: flex; flex-direction: column;
    transition: width .25s ease;
}
.ai-history-sidebar.open { width: 220px; }
.ai-history-sidebar-header {
    padding: 12px 14px; font-size: 12px; font-weight: 700;
    color: #475569; letter-spacing: .3px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
}
.ai-history-list {
    flex: 1; overflow-y: auto; padding: 4px;
}
.ai-history-list::-webkit-scrollbar { width: 3px; }
.ai-history-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.ai-history-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 10px; cursor: pointer;
    transition: all .15s; margin-bottom: 2px;
    position: relative;
}
.ai-history-item:hover { background: #e2e8f0; }
.ai-history-item.active { background: #ede9fe; }
.ai-history-item-icon {
    width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; background: #e2e8f0;
}
.ai-history-item.active .ai-history-item-icon { background: #c4b5fd; }
.ai-history-item-info { flex: 1; min-width: 0; }
.ai-history-item-title {
    font-size: 12px; font-weight: 600; color: #1e293b;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-history-item-meta {
    font-size: 10px; color: #94a3b8; margin-top: 1px;
}
.ai-history-item-delete {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 22px; height: 22px; border: none; background: transparent;
    border-radius: 6px; cursor: pointer; color: #94a3b8; font-size: 12px;
    display: none; align-items: center; justify-content: center;
    transition: all .15s;
}
.ai-history-item:hover .ai-history-item-delete { display: flex; }
.ai-history-item-delete:hover { background: #fee2e2; color: #ef4444; }
.ai-history-empty {
    padding: 20px 12px; text-align: center; font-size: 11px; color: #94a3b8;
}
.ai-history-toggle {
    width: 28px; height: 28px; border: none; background: transparent;
    border-radius: 8px; cursor: pointer; color: #64748b;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s; font-size: 14px;
}
.ai-history-toggle:hover { background: #e2e8f0; color: #334155; }
.ai-history-toggle.active { background: #ede9fe; color: #6366f1; }
.ai-chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.ai-suggestions, .ai-input-area { flex-shrink: 0; }
.ai-msg-time { font-size: 10px; color: #94a3b8; margin-top: 3px; padding-left: 2px; }
.ai-msg.user .ai-msg-time { text-align: right; padding-right: 2px; }

/* Message actions */
.ai-msg-actions {
    display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .2s;
}
.ai-msg:hover .ai-msg-actions { opacity: 1; }
.ai-msg.user .ai-msg-actions { justify-content: flex-end; }
.ai-msg-action {
    padding: 3px 8px; border: none; background: transparent; color: #94a3b8;
    font-size: 11px; cursor: pointer; border-radius: 6px; transition: all .15s;
    display: flex; align-items: center; gap: 3px; font-family: inherit;
}
.ai-msg-action:hover { background: #f1f5f9; color: #475569; }
.ai-msg-action.copied { color: #16a34a; background: #dcfce7; }

/* App cards in chat */
.ai-app-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.ai-app-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; background: #fff; border: 1px solid #e2e8f0;
    border-radius: 14px; cursor: pointer; transition: all .2s;
    text-decoration: none; color: inherit; position: relative; overflow: hidden;
}
.ai-app-card::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(99,102,241,.03), transparent); opacity: 0; transition: opacity .2s; }
.ai-app-card:hover::before { opacity: 1; }
.ai-app-card:hover { border-color: #a5b4fc; box-shadow: 0 4px 20px rgba(99,102,241,.1); transform: translateY(-2px); }
.ai-app-card-icon {
    width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    font-size: 22px; color: #fff; font-weight: 700; position: relative; z-index: 1;
}
.ai-app-card-icon img { width: 100%; height: 100%; object-fit: cover; }
.ai-app-card-info { flex: 1; min-width: 0; position: relative; z-index: 1; }
.ai-app-card-name { font-size: 13px; font-weight: 600; color: #1e293b; margin-bottom: 2px; }
.ai-app-card-desc { font-size: 11px; color: #64748b; display:-webkit-box;-webkit-line-clamp:1;line-clamp:1;-webkit-box-orient:vertical; overflow:hidden; }
.ai-app-card-tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; position: relative; z-index: 1; }
.ai-app-tag { font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 500; white-space: nowrap; letter-spacing: .2px; }
.ai-app-tag.subscribed { background: #dcfce7; color: #16a34a; }
.ai-app-tag.not-subscribed { background: #fef3c7; color: #b45309; }
.ai-app-tag.free { background: #dbeafe; color: #2563eb; }
.ai-app-tag.price { background: #fce7f3; color: #be185d; }
.ai-app-guide-link { display: inline-flex; align-items: center; gap: 2px; font-size: 10px; color: #6366f1; margin-top: 4px; text-decoration: none; transition: color .15s; }
.ai-app-guide-link:hover { color: #4f46e5; text-decoration: underline; }
.ai-app-card-arrow { color: #94a3b8; flex-shrink: 0; font-size: 20px; position: relative; z-index: 1; transition: transform .2s; }
.ai-app-card:hover .ai-app-card-arrow { transform: translateX(2px); color: #6366f1; }

/* Typing indicator */
.ai-typing { display: flex; gap: 4px; padding: 4px 0; align-items: center; }
.ai-typing-dot {
    width: 6px; height: 6px; border-radius: 50%; background: #94a3b8;
    animation: aiTypingBounce 1.4s infinite;
}
.ai-typing-dot:nth-child(2) { animation-delay: .2s; }
.ai-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes aiTypingBounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* Input area */
.ai-input-area { padding: 12px 16px 16px; border-top: 1px solid #f1f5f9; background: #fff; flex-shrink: 0; }
.ai-input-wrapper {
    display: flex; align-items: flex-end; gap: 8px;
    background: #f8fafc; border: 1.5px solid #e2e8f0;
    border-radius: 16px; padding: 8px 8px 8px 16px;
    transition: all .25s;
}
.ai-input-wrapper:focus-within { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(129,140,248,.08); background: #fff; }
#ai-input {
    flex: 1; border: none; background: transparent; outline: none;
    font-size: 14px; font-family: inherit; line-height: 1.5;
    resize: none; max-height: 120px; color: #1e293b; padding: 2px 0;
}
#ai-input::placeholder { color: #94a3b8; font-size: 13px; }
.ai-send-btn {
    width: 34px; height: 34px; border: none; border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all .2s; position: relative; overflow: hidden;
}
.ai-send-btn::after { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,.25), transparent); opacity: 0; transition: opacity .2s; }
.ai-send-btn:hover:not(:disabled)::after { opacity: 1; }
.ai-send-btn:hover:not(:disabled) { transform: scale(1.06); box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.ai-send-btn:disabled { opacity: .3; cursor: not-allowed; filter: grayscale(.5); }
.ai-send-btn svg { width: 16px; height: 16px; position: relative; z-index: 1; }
.ai-input-disclaimer { text-align: center; font-size: 10px; color: #cbd5e1; margin-top: 6px; }

/* Error state */
.ai-error-msg { background: #fef2f2; border: 1px solid #fecaca; border-radius: 12px; padding: 12px 14px; font-size: 12px; color: #991b1b; }
.ai-error-retry { margin-top: 8px; padding: 5px 12px; border: 1px solid #fca5a5; background: #fff; color: #dc2626; border-radius: 8px; cursor: pointer; font-size: 11px; font-family: inherit; transition: all .15s; }
.ai-error-retry:hover { background: #fef2f2; }

/* Responsive */
@media (max-width: 640px) {
    .ai-float-btn { bottom: 16px; right: 12px; padding: 10px 14px; font-size: 13px; border-radius: 26px; }
    .ai-float-label { display: none; }
    .ai-float-icon svg { width: 20px; height: 20px; }
    .ai-panel { width: 100vw; border-radius: 0; }
    .ai-msg-bubble { max-width: 88%; font-size: 13px; }
    .ai-suggestions { padding: 12px 16px; }
    .ai-messages { padding: 12px 14px; gap: 6px; }
    .ai-input-area { padding: 10px 12px 14px; }
    .ai-welcome { padding: 24px 12px; }
    .ai-welcome-icon { font-size: 40px; }
    .ai-app-card { padding: 10px 12px; }
    .ai-app-card-icon { width: 40px; height: 40px; font-size: 18px; }
    .ai-msg-actions { opacity: 1; }
}
