/* ============================================================
   Modern Style — Apple-inspired Minimal Design
   Core CSS for all pages
   ============================================================ */

/* --- Design Tokens --- */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #0f172a;
    --accent: #38bdf8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --bg-body: #eef4ff;
    --bg-surface: rgba(255, 255, 255, 0.84);
    --bg-elevated: rgba(255, 255, 255, 0.74);
    --bg-panel: rgba(15, 23, 42, 0.96);
    --line-soft: rgba(148, 163, 184, 0.16);

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.03);
    --shadow-sm: 0 10px 24px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 18px 40px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 58px rgba(15, 23, 42, 0.11);
    --shadow-xl: 0 36px 80px rgba(15, 23, 42, 0.14);

    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-xl: 30px;
    --radius-2xl: 38px;

    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* --- Base --- */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    touch-action: manipulation;
    overflow-x: hidden;
    background-color: var(--bg-body);
}

body {
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.16), transparent 28%),
        radial-gradient(circle at 85% 12%, rgba(16, 185, 129, 0.12), transparent 24%),
        radial-gradient(circle at 78% 78%, rgba(245, 158, 11, 0.1), transparent 22%),
        linear-gradient(180deg, #f8fbff 0%, #eef4ff 52%, #f6f9ff 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
    letter-spacing: -0.01em;
}

/* --- Back to Top Button --- */
.back-to-top-btn {
    position: fixed !important;
    bottom: 24px !important;
    right: 20px !important;
    width: 40px !important;
    height: 40px !important;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    z-index: 999999 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0 !important;
    transform: translateY(0) !important;
    transition: opacity var(--transition-normal), transform var(--transition-normal),
        box-shadow var(--transition-normal) !important;
    box-shadow: var(--shadow-md) !important;
    pointer-events: all !important;
    backdrop-filter: blur(12px) !important;
}

.back-to-top-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: var(--shadow-lg) !important;
}

.back-to-top-btn:active {
    transform: translateY(0) scale(0.96) !important;
}

.back-to-top-btn i {
    font-size: 14px !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* --- Main Content --- */
.main-content {
    max-width: 460px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    padding-bottom: 96px;
    min-height: calc(100vh - 80px);
    position: relative;
    z-index: 1;
    isolation: isolate;
}

@media (min-width: 430px) {
    .main-content {
        padding-top: var(--spacing-sm);
        margin-bottom: var(--spacing-lg);
    }
}

/* --- Poster --- */
.poster-container {
    margin-top: 0;
    margin-bottom: var(--spacing-lg);
    position: relative;
}

.poster-banner {
    position: relative;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    display: block;
    height: 180px;
    background: linear-gradient(135deg, rgba(255,255,255,0.92) 0%, rgba(219,234,254,0.92) 100%);
    border: 1px solid rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(22px);
}

.poster-banner:hover {
    box-shadow: var(--shadow-lg);
}

.poster-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
    background: transparent;
}

.poster-banner:hover .poster-image {
    transform: none;
}

.poster-placeholder {
    height: 180px;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.poster-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.12) 0%,
        rgba(255, 255, 255, 0) 60%
    );
}

.poster-content {
    text-align: center;
    color: #fff;
    z-index: 3;
    position: relative;
}

.poster-content i {
    font-size: 3rem;
    margin-bottom: var(--spacing-sm);
    opacity: 0.9;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

.poster-content p {
    font-size: 1.05rem;
    font-weight: 600;
    opacity: 0.95;
    letter-spacing: 0.02em;
}

/* --- Platform Navigation (Home Page) --- */
.home-page .platform-navigation {
    position: relative;
    width: 100%;
    z-index: 10;
    margin-bottom: var(--spacing-lg);
}

.home-page .nav-tabs {
    display: flex;
    background: var(--bg-elevated);
    border-radius: 0;
    padding: 6px;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.78);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.home-page .nav-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    border-radius: 0;
    cursor: pointer;
    min-height: 42px;
    transition: color var(--transition-normal), background var(--transition-normal);
    -webkit-tap-highlight-color: transparent;
}

.home-page .nav-tab:hover:not(.active) {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.08);
}

.home-page .nav-tab.active {
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #0ea5e9);
    box-shadow: 0 12px 28px rgba(59, 130, 246, 0.28);
}

/* --- Features --- */
.features-container {
    margin-top: var(--spacing-lg);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.feature-item {
    background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(255,255,255,0.64));
    border-radius: 18px;
    padding: 10px 4px 8px;
    text-align: center;
    cursor: pointer;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    min-height: 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.feature-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.feature-item:active {
    transform: translateY(0);
}

.feature-icon {
    width: auto;
    height: auto;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: transparent;
    transition: transform var(--transition-normal);
}

.feature-icon svg,
.feature-icon i,
.feature-icon img {
    transform: scale(0.88);
    transform-origin: center;
}

.feature-icon .emoji {
    font-size: 22px;
    line-height: 1;
}

.feature-item:hover .feature-icon {
    transform: scale(1.05);
}

/* Soft gradient backgrounds for specific features */
.feature-item[data-feature="benchmark"] .feature-icon {
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
}

.feature-item[data-feature="product"] .feature-icon {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
}

.feature-item[data-feature="viral"] .feature-icon {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.feature-item[data-feature="refresh"] .feature-icon {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
}

.features-container#douyinFeatures .feature-item[data-feature="hotSearch"] .feature-icon {
    background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%);
}

.features-container#douyinFeatures .feature-item[data-feature="benchmarkVideo"] .feature-icon {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.feature-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0;
    letter-spacing: 0.01em;
    line-height: 1.2;
}

.feature-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.06) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

.feature-item:hover .feature-glow {
    opacity: 1;
}

/* --- Responsive --- */
@media (max-width: 430px) {
    .main-content {
        padding-left: 14px;
        padding-right: 14px;
    }

    .main-content.profile-page,
    .main-content.ai-writer-page {
        padding-left: 0;
        padding-right: 0;
    }

    .features-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 10px;
    }
}

@media (max-width: 375px) {
    .main-content {
        padding-left: var(--spacing-sm);
        padding-right: var(--spacing-sm);
    }

    .main-content.profile-page,
    .main-content.ai-writer-page {
        padding-left: 0;
        padding-right: 0;
    }

    .features-grid {
        gap: 10px;
    }

    .feature-item {
        padding: var(--spacing-md);
        min-height: 110px;
    }

    .feature-icon {
        width: 48px;
        height: 48px;
    }

    .feature-icon .emoji {
        font-size: 20px;
    }

    .feature-text {
        font-size: 13px;
    }
}

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

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f0f1f4;
        --text-secondary: #9ca3af;
        --text-muted: #6b7280;

        --bg-body: #0f1117;
        --bg-surface: rgba(255, 255, 255, 0.06);
        --bg-elevated: rgba(255, 255, 255, 0.08);

        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.35);
        --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.4);
    }

    html {
        background-color: #0f1117;
    }

    body {
        background-color: #0f1117;
    }

    .poster-banner {
        background: linear-gradient(135deg, #1a1d2e 0%, #1e2035 100%);
        border-color: rgba(255, 255, 255, 0.06);
    }

    .poster-placeholder {
        box-shadow: var(--shadow-md);
    }

    .home-page .nav-tabs {
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.08);
    }

    .home-page .nav-tab {
        color: var(--text-muted);
    }

    .home-page .nav-tab:hover:not(.active) {
        background: rgba(102, 126, 234, 0.1);
        color: #8b9cf7;
    }

    .home-page .nav-tab.active {
        background: var(--primary);
        color: #fff;
        box-shadow: 0 2px 10px rgba(102, 126, 234, 0.35);
    }

    .feature-item {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.07);
    }

    .feature-item:hover {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .feature-icon {
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
    }

    .feature-item[data-feature="benchmark"] .feature-icon {
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.15) 100%);
    }

    .feature-item[data-feature="product"] .feature-icon {
        background: linear-gradient(135deg, rgba(240, 147, 251, 0.2) 0%, rgba(245, 87, 108, 0.12) 100%);
    }

    .feature-item[data-feature="viral"] .feature-icon {
        background: linear-gradient(135deg, rgba(79, 172, 254, 0.2) 0%, rgba(0, 242, 254, 0.1) 100%);
    }

    .feature-item[data-feature="refresh"] .feature-icon {
        background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(56, 249, 215, 0.1) 100%);
    }

    .features-container#douyinFeatures .feature-item[data-feature="hotSearch"] .feature-icon {
        background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(251, 191, 36, 0.1) 100%);
    }

    .features-container#douyinFeatures .feature-item[data-feature="benchmarkVideo"] .feature-icon {
        background: linear-gradient(135deg, rgba(79, 172, 254, 0.2) 0%, rgba(96, 165, 250, 0.1) 100%);
    }

    .feature-glow {
        background: radial-gradient(circle, rgba(102, 126, 234, 0.1) 0%, transparent 70%);
    }

    .back-to-top-btn {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
    }
}

/* --- Print --- */
@media print {
    body {
        background: #fff;
    }

    .back-to-top-btn {
        display: none !important;
    }
}
