/* ===== 基础重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ===== 主容器 ===== */
.app-wrapper {
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
    background: linear-gradient(160deg, #f8f9fe 0%, #eef0f7 40%, #e8ecf5 100%);
}

/* ===== 背景装饰层 ===== */
.bg-layer {
    position: fixed;
    top: 0;
    left: 50%;
    width: 480px;
    height: 100%;
    transform: translateX(-50%);
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

/* 浮动渐变圆 - 纯CSS装饰 */
.bg-layer::before,
.bg-layer::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.3;
    will-change: transform;
}

.bg-layer::before {
    width: 280px;
    height: 280px;
    background: #818cf8;
    top: -60px;
    right: -40px;
    animation: floatBubble 8s ease-in-out infinite;
}

.bg-layer::after {
    width: 220px;
    height: 220px;
    background: #a78bfa;
    bottom: 100px;
    left: -50px;
    animation: floatBubble 10s ease-in-out infinite reverse;
}

/* 第三个装饰圆 - 使用额外伪元素不可能，用额外div实现？直接用bg-layer加第三个圆不方便，用box-shadow模拟 */
/* 实际上我在HTML里加了一个额外的装饰元素 */

@keyframes floatBubble {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(20px, -30px) scale(1.05); }
    50% { transform: translate(-10px, 10px) scale(0.95); }
    75% { transform: translate(15px, -10px) scale(1.02); }
}

/* 第二个装饰点 - 放在bg-layer内的额外span实现（将在HTML中添加） */
.bg-dot {
    position: absolute;
    border-radius: 50%;
    filter: blur(50px);
    opacity: 0.25;
    pointer-events: none;
    will-change: transform;
}

.bg-dot-1 {
    width: 180px;
    height: 180px;
    background: #60a5fa;
    top: 40%;
    right: -30px;
    animation: floatBubble 9s ease-in-out infinite 1s;
}

.bg-dot-2 {
    width: 150px;
    height: 150px;
    background: #f472b6;
    bottom: 30%;
    left: -20px;
    animation: floatBubble 7s ease-in-out infinite 2s;
}

/* ===== 顶部导航 (玻璃效果) ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 20px;
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
}

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background: linear-gradient(135deg, #c7d2fe, #a5b4fc);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.header-avatar:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.header-title {
    font-size: 19px;
    font-weight: 700;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
    line-height: 1;
}

.header-search {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.08);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #4f46e5;
    flex-shrink: 0;
    transition: background 0.25s ease, transform 0.25s ease;
}

.header-search:hover {
    background: rgba(99, 102, 241, 0.16);
}

.header-search:active {
    transform: scale(0.9);
    background: rgba(99, 102, 241, 0.2);
}

.header-search svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* ===== 主体内容 ===== */
.app-main {
    position: relative;
    z-index: 1;
    padding: 8px 0 40px;
    /* 所有子元素默认隐藏，通过动画逐一亮相 */
}

/* ===== 分区标题 ===== */
.section-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 20px 20px;
    animation: fadeIn 0.6s ease both;
}

.section-title:nth-of-type(1) { animation-delay: 0.1s; }
.section-title:nth-of-type(2) { animation-delay: 0.5s; }

.section-title .line {
    width: 32px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, #a5b4fc, transparent);
    flex-shrink: 0;
}

.section-title .text {
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 3px;
    text-transform: uppercase;
    line-height: 1;
    flex-shrink: 0;
    position: relative;
}

.section-title .text::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, #818cf8, #a78bfa);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.section-title .text:hover::after {
    opacity: 1;
}

/* ===== 应用卡片 ===== */
.app-card {
    background: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-radius: 18px;
    margin: 0 18px 14px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow:
        0 2px 12px rgba(99, 102, 241, 0.06),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    will-change: transform;
    animation: cardEntry 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.app-card:nth-child(2) { animation-delay: 0.15s; }
.app-card:nth-child(3) { animation-delay: 0.25s; }
.app-card:nth-child(4) { animation-delay: 0.35s; }
.app-card:nth-child(5) { animation-delay: 0.45s; }

.app-card:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow:
        0 8px 28px rgba(99, 102, 241, 0.10),
        0 0 0 1px rgba(255, 255, 255, 0.7) inset;
    border-color: rgba(129, 140, 248, 0.25);
}

.app-card:active {
    transform: scale(0.985);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.06);
}

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

/* 图标容器 */
.app-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    margin-right: 16px;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9ff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.app-card:hover .app-icon {
    transform: scale(1.05);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.12);
}

.icon-svg {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* 图标加载失败时的文字降级 */
.icon-fallback {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    border-radius: inherit;
}

.icon-svg[style*="display:none"] + .icon-fallback,
.icon-svg[style*="display: none"] + .icon-fallback {
    display: flex;
}

.app-card:nth-child(2) .icon-fallback {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.app-card:nth-child(3) .icon-fallback {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

/* 信息区 */
.app-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.app-name {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
    letter-spacing: 0.3px;
}

.app-version {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    color: #6366f1;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    line-height: 1.3;
    font-weight: 600;
    letter-spacing: 0.3px;
    border: 1px solid rgba(99, 102, 241, 0.08);
}

.app-desc {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== 下载按钮（渐变动画） ===== */
.download-btn {
    position: relative;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 12px;
    font-family: inherit;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    z-index: 1;
}

/* 按钮微光动画 */
.download-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
    z-index: 0;
    pointer-events: none;
}

.download-btn:hover::before {
    left: 100%;
}

.download-btn span {
    position: relative;
    z-index: 1;
}

.download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.download-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

/* ===== 搜索遮罩 ===== */
.search-overlay {
    position: fixed;
    top: 0;
    left: 50%;
    width: 100%;
    max-width: 480px;
    height: 100%;
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(30px) saturate(1.2);
    backdrop-filter: blur(30px) saturate(1.2);
    z-index: 100;
    transform: translate(-50%, -100%);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    visibility: hidden;
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0.4s;
}

.search-overlay.active {
    transform: translate(-50%, 0);
    visibility: visible;
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0s;
}

.search-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    height: 60px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.search-input {
    flex: 1;
    height: 40px;
    background: rgba(0, 0, 0, 0.04);
    border: none;
    border-radius: 12px;
    padding: 0 16px;
    font-size: 16px;
    color: #1e293b;
    outline: none;
    font-family: inherit;
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.search-input:focus {
    background: rgba(99, 102, 241, 0.06);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.search-input::placeholder {
    color: #94a3b8;
}

.search-cancel {
    font-size: 15px;
    color: #6366f1;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    padding: 6px 4px;
    transition: opacity 0.2s ease;
}

.search-cancel:hover {
    opacity: 0.7;
}

.search-cancel:active {
    opacity: 0.5;
}

/* ===== Toast 提示 ===== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(15, 23, 42, 0.82);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: #ffffff;
    padding: 14px 28px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 200;
    white-space: nowrap;
    font-family: inherit;
    letter-spacing: 0.3px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ===== 通用动画 ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== 桌面端适配 ===== */
@media (min-width: 481px) {
    body {
        background: #e8ecf4;
    }
    .app-wrapper {
        box-shadow: 0 0 30px rgba(99, 102, 241, 0.06);
        border-left: 1px solid rgba(255, 255, 255, 0.3);
        border-right: 1px solid rgba(255, 255, 255, 0.3);
    }
    .bg-layer {
        width: 480px;
    }
}

/* ===== 移动端精细调校 ===== */
@media (max-width: 380px) {
    .app-header {
        height: 54px;
        padding: 0 14px;
    }
    .app-card {
        margin: 0 12px 12px;
        padding: 14px 14px;
        border-radius: 16px;
    }
    .app-icon {
        width: 48px;
        height: 48px;
        margin-right: 12px;
        border-radius: 14px;
    }
    .app-name {
        font-size: 15px;
    }
    .download-btn {
        padding: 7px 13px;
        font-size: 12px;
    }
}

/* 减少动画偏好 - 尊重用户系统设置 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
