/*
Theme Name: wpcoder-apk
Theme URI: https://wpcoder.cn
Author: wpcoder
Version: 1.0.0
*/

@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: local('Roboto Light'), local('Roboto-Light'), url('./assets/fonts/roboto/Roboto-300.woff2') format('woff2'), url('./assets/fonts/roboto/Roboto-300.ttf') format('truetype');
}

@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: local('Roboto Regular'), local('Roboto'), url('./assets/fonts/roboto/Roboto-400.woff2') format('woff2'), url('./assets/fonts/roboto/Roboto-400.ttf') format('truetype');
}

@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: local('Roboto Medium'), local('Roboto-Medium'), url('./assets/fonts/roboto/Roboto-500.woff2') format('woff2'), url('./assets/fonts/roboto/Roboto-500.ttf') format('truetype');
}

@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: local('Roboto Bold'), local('Roboto-Bold'), url('./assets/fonts/roboto/Roboto-700.woff2') format('woff2'), url('./assets/fonts/roboto/Roboto-700.ttf') format('truetype');
}

:root {
    --primary: #24a159;
    --primary-dark: #1e8a4b;
    --primary-light: #e9f6ef;
    --bg-main: #ffffff;
    --bg-secondary: #f8f8f8;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #f0f0f0;
    --shadow-soft: 0 2px 10px rgba(0, 0, 0, 0.05);
    --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --header-height: 64px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0px 20px;
}

.apk-breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.apk-breadcrumb-link {
    color: var(--text-secondary);
}

.apk-breadcrumb-link:hover {
    color: var(--primary);
}

.apk-breadcrumb-sep {
    color: #b3b8bf;
}

.apk-breadcrumb-current {
    color: var(--text-primary);
    font-weight: 600;
}

@media (max-width: 640px) {
    .apk-breadcrumbs {
        gap: 6px;
        font-size: 0.82rem;
        margin-bottom: 12px;
    }
}

/* Header Styles */
header {
    background: rgba(255, 255, 255, 0.88);
    height: var(--header-height);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    backdrop-filter: saturate(165%) blur(14px);
    -webkit-backdrop-filter: saturate(165%) blur(14px);
}

header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.05));
    pointer-events: none;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    position: relative;
    z-index: 1;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px 0 8px 8px;
    /* Classic APKPure icon shape */
    position: relative;
    font-weight: 900;
    font-size: 1.4rem;
}

.logo-icon::after {
    content: "A";
    /* text-transform: lowercase; */
}

.search-bar {
    flex: 1;
    max-width: 500px;
    margin: 0 40px;
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 12px 20px 12px 48px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background: #f1f3f4;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-bar input:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(36, 161, 89, 0.15);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-submit {
    position: absolute;
    left: 0;
    top: 0;
    width: 48px;
    height: 100%;
    background: transparent;
    border: 0;
    padding: 0;
}

nav .primary-menu {
    display: flex;
    gap: 25px;
    align-items: center;
}

nav .primary-menu > li {
    position: relative;
}

nav .primary-menu > li > a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
}

nav .primary-menu > li.menu-item-has-children > a::after,
nav .primary-menu > li.page_item_has_children > a::after {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
    transition: transform 0.2s ease;
}

nav .primary-menu > li:hover > a::after,
nav .primary-menu > li:focus-within > a::after {
    transform: rotate(225deg) translateY(-1px);
}

@media (max-width: 768px) {
    header {
        height: auto;
        padding: 10px 0;
    }

    .header-inner {
        flex-wrap: wrap;
        gap: 8px;
    }

    .logo {
        order: 1;
        flex: 0 1 auto;
        min-width: 0;
        max-width: 36%;
        gap: 6px;
        font-size: 1.15rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .logo-icon {
        width: 30px;
        height: 30px;
        font-size: 1.15rem;
        flex-shrink: 0;
    }

    .search-bar {
        order: 1;
        flex: 1 1 0;
        min-width: 0;
        margin: 0;
        max-width: none;
    }

    .search-bar input {
        padding: 10px 14px 10px 38px;
        font-size: 0.92rem;
    }

    .search-submit {
        width: 38px;
    }

    .header-actions {
        order: 1;
        margin-left: 0;
        margin-left: auto;
        flex: 0 0 auto;
        flex-shrink: 0;
        gap: 6px;
        white-space: nowrap;
    }

    nav {
        order: 2;
        flex-basis: 100%;
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
    }

    nav .primary-menu {
        gap: 20px;
        width: max-content;
        padding: 0 5px;
    }
}

nav .primary-menu > li > a {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

nav .primary-menu > li > a:hover,
nav .primary-menu > li > a.active {
    color: var(--primary);
}

nav .primary-menu > li.current-menu-item > a,
nav .primary-menu > li.current-menu-parent > a,
nav .primary-menu > li.current-menu-ancestor > a,
nav .primary-menu > li.current-post-ancestor > a,
nav .primary-menu > li.current-category-ancestor > a,
nav .primary-menu > li.current-cat-ancestor > a,
nav .primary-menu > li.current_page_item > a,
nav .primary-menu > li.current_page_parent > a {
    color: var(--primary);
    font-weight: 700;
}

nav .primary-menu .sub-menu,
nav .primary-menu .children {
    position: absolute;
    left: 0;
    top: 100%;
    min-width: 200px;
    padding: 8px 0;
    margin: 0;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.74);
    border-radius: 10px;
    box-shadow: 0 14px 32px rgba(14, 30, 37, 0.14);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    display: block;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

nav .primary-menu li:hover > .sub-menu,
nav .primary-menu li:focus-within > .sub-menu,
nav .primary-menu li:hover > .children,
nav .primary-menu li:focus-within > .children {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

nav .primary-menu .sub-menu li,
nav .primary-menu .children li {
    display: block;
}

nav .primary-menu .sub-menu a,
nav .primary-menu .children a {
    display: block;
    padding: 8px 14px;
    color: var(--text-secondary);
    font-size: 0.93rem;
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
}

nav .primary-menu .sub-menu a:hover,
nav .primary-menu .children a:hover,
nav .primary-menu .sub-menu .current-menu-item > a,
nav .primary-menu .sub-menu .current_page_item > a,
nav .primary-menu .children .current_page_item > a,
nav .primary-menu .children .current_page_parent > a,
nav .primary-menu .children .current_page_ancestor > a {
    color: var(--primary);
    background: rgba(36, 161, 89, 0.08);
}

nav .primary-menu .sub-menu .sub-menu,
nav .primary-menu .children .children,
nav .primary-menu .sub-menu .children,
nav .primary-menu .children .sub-menu {
    left: 100%;
    top: -8px;
}

@media (max-width: 768px) {
    nav .primary-menu .sub-menu,
    nav .primary-menu .children {
        left: 0;
        right: auto;
    }
}

.header-actions {
    display: flex;
    gap: 15px;
    margin-left: 20px;
}

.btn-icon {
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.2rem;
}

/* Sections */
.main-wrapper {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 30px;
    padding-top: 30px;
    padding-bottom: 50px;
}

@media (max-width: 992px) {
    .main-wrapper {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: block;
    }
}

section {
    background: var(--bg-main);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-soft);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.view-more {
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Hero Carousel */
.hero-carousel {
    height: clamp(240px, 38vw, 460px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-medium);
    margin-top: 20px;
    margin-bottom: 20px;
}

.hero-slide {
    width: 100%;
    height: 100%;
    position: relative;
    background: #000;
}

.hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0.9;
    transition: transform 10s linear;
}

.hero-carousel:hover .hero-img {
    transform: scale(1.1);
}

.hero-content {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    box-sizing: border-box;
    padding: clamp(20px, 8.5vw, 92px) clamp(16px, 5vw, 50px) clamp(16px, 4.5vw, 44px);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.58) 58%, rgba(0, 0, 0, 0.24) 100%);
    color: white;
}

.hero-info {
    max-width: min(760px, 100%);
}

.hero-info h1 {
    font-size: clamp(1.35rem, 4.4vw, 3rem);
    font-weight: 800;
    line-height: 1.12;
    margin-bottom: clamp(8px, 1.8vw, 15px);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.hero-info p {
    font-size: clamp(0.86rem, 1.4vw, 1.08rem);
    max-width: min(66ch, 100%);
    opacity: 0.9;
    margin-bottom: clamp(12px, 2.4vw, 25px);
}

.hero-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(38px, 5vw, 44px);
    padding: 0 clamp(16px, 2.5vw, 24px);
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: clamp(0.82rem, 1.25vw, 0.95rem);
    line-height: 1;
}

.hero-cta:hover {
    transform: translateY(-2px);
    background: var(--primary-dark);
}

@media (max-width: 768px) {
    .hero-carousel {
        height: clamp(220px, 56vw, 320px);
        margin-top: 14px;
        margin-bottom: 18px;
    }

    .hero-info h1 {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .hero-info p {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

@media (max-width: 480px) {
    .hero-carousel {
        height: clamp(210px, 62vw, 280px);
    }

    .hero-content {
        padding-top: 44px;
    }

    .hero-cta {
        width: 100%;
        max-width: 190px;
    }
}

.home-sidebar-promo {
    overflow: hidden;
}

.sidebar-promo-content {
    border-radius: 12px;
    overflow: hidden;
    background: #f5f7fb;
    min-height: 60px;
}

.sidebar-promo-content > * {
    max-width: 100%;
}

.sidebar-promo-content img,
.sidebar-promo-content iframe {
    width: 100%;
    max-width: 100%;
    display: block;
    border: 0;
}

/* App Grid */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 20px;
}

.app-empty {
    grid-column: 1 / -1;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f5f7fb;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.app-grid.is-loading,
.ranking-list.is-loading {
    pointer-events: none;
}

.app-skeleton-card,
.ranking-skeleton-item {
    position: relative;
    overflow: hidden;
}

.app-skeleton-card::after,
.ranking-skeleton-item::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.6) 45%, transparent 100%);
    animation: apkShimmer 1.2s ease-in-out infinite;
}

.app-skeleton-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-skeleton-thumb,
.app-skeleton-line,
.ranking-skeleton-index,
.ranking-skeleton-thumb,
.ranking-skeleton-line {
    background: #eef1f4;
    border-radius: 10px;
}

.app-skeleton-thumb {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 20px;
}

.app-skeleton-line {
    height: 12px;
    width: 92%;
}

.app-skeleton-line.short {
    width: 58%;
}

.ranking-skeleton-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
}

.ranking-skeleton-index {
    width: 18px;
    height: 18px;
    border-radius: 4px;
}

.ranking-skeleton-thumb {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    flex-shrink: 0;
}

.ranking-skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ranking-skeleton-line {
    height: 10px;
    width: 90%;
}

.ranking-skeleton-line.short {
    width: 60%;
}

.section-reveal-item {
    opacity: 0;
    transform: translateY(10px);
    animation: apkReveal 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

@keyframes apkShimmer {
    to {
        transform: translateX(100%);
    }
}

@keyframes apkReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-skeleton-card::after,
    .ranking-skeleton-item::after,
    .section-reveal-item {
        animation: none;
    }

    .section-reveal-item {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 576px) {
    .app-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 15px;
    }

    .app-name {
        font-size: 0.85rem;
    }
}

.app-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    transition: transform 0.3s ease;
}

.app-card:hover {
    transform: translateY(-5px);
}

.app-icon-wrapper {
    width: 80%;
    aspect-ratio: 1;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 10px;
    box-shadow: var(--shadow-soft);
}

.app-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-name {
    font-weight: 500;
    font-size: 0.95rem;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.app-category {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.app-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: #ffa800;
    margin-top: 2px;
}

/* Sidebar Ranking */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 15px;
    border-radius: 10px;
    padding: 6px 8px;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.ranking-item:hover {
    background: #f7f8f9;
    transform: translateY(-2px);
}

.rank-number {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-muted);
    width: 25px;
}

.ranking-item:nth-child(1) .rank-number {
    color: #f4b400;
}

.ranking-item:nth-child(2) .rank-number {
    color: #9aa0a6;
}

.ranking-item:nth-child(3) .rank-number {
    color: #3c4043;
}

.rank-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
}

.rank-info {
    flex: 1;
}

.rank-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.rank-name a {
    color: inherit;
    transition: color 0.2s ease;
}

.ranking-item:hover .rank-name a {
    color: var(--primary);
}

.rank-btn {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.ranking-item:hover .rank-btn {
    background: var(--primary);
    color: #fff;
}

/* Categories List */
.category-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.badge {
    padding: 8px 16px;
    background: #f1f3f4;
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.badge:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* Footer */
footer {
    background: #222;
    color: #999;
    padding: 60px 0 30px;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 40px;
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
}

@media (max-width: 480px) {
    .footer-grid {
        grid-template-columns: 1fr;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
}

.footer-col h4 {
    color: white;
    margin-bottom: 20px;
    font-size: 1rem;
}

.footer-links li {
    margin-bottom: 10px;
}

.footer-links a:hover {
    color: white;
}

.footer-bottom {
    border-top: 1px solid #333;
    padding-top: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.social-links {
    display: flex;
    gap: 20px;
}

.social-links a {
    font-size: 1.2rem;
}

/* Header Actions Styles */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.user-info img {
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

.user-info span {
    font-size: 0.9rem;
}

.logout-link {
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-left: 10px;
}

.logout-link:hover {
    color: var(--primary-dark);
}

.btn-login,
.btn-register {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-login {
    background: var(--primary);
    color: white;
}

.btn-login:hover {
    background: var(--primary-dark);
}

.btn-register {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-register:hover {
    background: var(--primary);
    color: white;
}

@media (max-width: 768px) {
    .header-actions {
        gap: 6px;
    }

    .btn-login,
    .btn-register {
        padding: 6px 9px;
        font-size: 0.78rem;
    }

    .user-info {
        gap: 6px;
    }

    .user-info img {
        width: 28px;
        height: 28px;
    }

    .user-info span {
        display: none; /* Hide welcome text on mobile */
    }

    .logout-link {
        margin-left: 2px;
        font-size: 0.78rem;
    }

    .btn-register {
        display: none;
    }
}

/* Single App Detail */
.single-post .app-detail-header {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 30px;
    padding: 40px;
    background: white;
    border-radius: var(--radius-lg);
    margin-bottom: 30px;
    box-shadow: var(--shadow-soft);
}

.single-post .app-detail-icon {
    width: 180px;
    height: 180px;
    border-radius: 40px;
    box-shadow: var(--shadow-medium);
    object-fit: cover;
}

.single-post .app-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.single-post .app-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.single-post .app-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.single-post .install-row {
    display: flex;
    gap: 15px;
    align-items: center;
}

.single-post #single-rating-btn,
.single-post #single-share-btn {
    transition: background-color 0.2s ease, color 0.2s ease;
}

.single-post #single-rating-btn:hover,
.single-post #single-share-btn:hover {
    background: var(--primary-dark) !important;
    color: #fff;
}

.single-post #single-rating-btn:hover i[data-lucide="heart"] {
    fill: #fff;
    stroke: #fff;
}

.single-post #single-rating-btn:disabled,
.single-post #single-rating-btn:disabled:hover {
    background: #e9f6ef !important;
    color: #1e8a4b;
}

.single-post .btn-install {
    background: var(--primary);
    color: white;
    padding: 15px 40px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(36, 161, 89, 0.3);
}

.single-post .btn-install:hover {
    transform: translateY(-2px);
    background: var(--primary-dark);
}

.single-post .btn-install.is-loading {
    opacity: 0.92;
}

.single-post .btn-install.is-loading svg {
    animation: apkDownloadModalSpin 0.9s linear infinite;
}

.single-post .screenshot-gallery {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 15px;
    margin-bottom: 30px;
}

.single-post .screenshot-gallery img {
    height: 400px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.3s;
}

.single-post .screenshot-gallery img:hover {
    transform: scale(1.02);
}

.single-post .description-content {
    line-height: 1.8;
    color: var(--text-secondary);
}

.single-post .tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.single-post .tag {
    padding: 5px 15px;
    background: #eee;
    border-radius: 20px;
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .single-post .app-detail-header {
        grid-template-columns: 1fr;
        text-align: center;
        padding: 20px;
        gap: 20px;
    }

    .single-post .app-detail-icon {
        width: 120px;
        height: 120px;
        margin: 0 auto;
    }

    .single-post .app-title {
        font-size: 1.5rem;
    }

    .single-post .app-meta {
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
        font-size: 0.85rem;
    }

    .single-post .install-row {
        flex-direction: column;
        width: 100%;
    }

    .single-post .btn-install {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }

    .single-post .screenshot-gallery img {
        height: 280px;
    }
}

/* Category Page */
.category-page {
    padding-top: 30px;
    padding-bottom: 40px;
}

.category-page-header {
    margin-bottom: 20px;
}

.category-page-header h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.category-page-header p {
    color: var(--text-secondary);
}

.category-page-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    align-items: start;
}

.category-sidebar section,
.category-content {
    margin-bottom: 0;
}

/* Tag Page: keep tag list in horizontal multi-column layout on all screen sizes */
.tag-page .category-page-layout {
    grid-template-columns: 1fr;
    gap: 16px;
}

.tag-page .category-nav-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.tag-page .category-nav-item {
    min-width: 0;
}

.tag-page .category-nav-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-nav-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.category-nav-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    background: #f7f8f9;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.category-nav-item:hover {
    color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(17, 24, 39, 0.06);
}

.category-nav-item.active {
    color: white;
    background: var(--primary);
}

.category-nav-name {
    font-weight: 600;
}

.category-nav-count {
    font-size: 0.8rem;
    opacity: 0.85;
}

.category-result-count {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.category-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-sort-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.category-sort-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.category-sort-select {
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.category-sort-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(36, 161, 89, 0.12);
}

.category-layout-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: 10px;
    background: #f1f3f4;
    box-shadow: inset 0 1px 2px rgba(17, 24, 39, 0.08);
    transition: box-shadow 0.24s ease, background-color 0.24s ease;
}

.category-layout-switch:focus-within {
    box-shadow: inset 0 1px 2px rgba(17, 24, 39, 0.08), 0 0 0 2px rgba(36, 161, 89, 0.18);
}

.layout-btn {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    will-change: transform, background-color, color, box-shadow;
    transition: color 0.22s ease, background-color 0.22s ease, transform 0.18s ease, box-shadow 0.22s ease;
}

.layout-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.layout-btn i {
    width: 16px;
    height: 16px;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.layout-btn:hover {
    color: var(--primary);
    background: #fff;
    transform: translateY(-1px);
}

.layout-btn:hover::after {
    opacity: 1;
}

.layout-btn:active {
    transform: translateY(0) scale(0.96);
}

.layout-btn.active {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 6px 12px rgba(36, 161, 89, 0.24);
    animation: apkLayoutBtnPop 0.2s ease;
}

.layout-btn.active i {
    transform: scale(1.08);
}

@keyframes apkLayoutBtnPop {
    0% {
        transform: scale(0.92);
    }
    100% {
        transform: scale(1);
    }
}

.category-app-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.category-app-list.layout-grid5 {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}

.category-app-list.is-layout-switching .category-app-item {
    animation: apkCategoryLayoutFade 0.38s cubic-bezier(0.2, 0.7, 0.2, 1);
    will-change: transform, opacity;
}

.category-app-list.is-layout-switching .category-app-item:nth-child(2n) {
    animation-delay: 0.05s;
}

.category-app-list.is-layout-switching .category-app-item:nth-child(3n) {
    animation-delay: 0.1s;
}

@keyframes apkCategoryLayoutFade {
    0% {
        opacity: 0.15;
        transform: translateY(16px) scale(0.965);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.category-app-list.layout-grid5 .category-app-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.category-app-list.layout-grid5 .category-app-thumb img {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    border-radius: 14px;
}

.category-app-list.layout-grid5 .category-app-main {
    width: 100%;
}

.category-app-list.layout-grid5 .category-app-title {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.category-app-list.layout-grid5 .category-app-meta {
    gap: 8px;
    font-size: 0.78rem;
    margin-bottom: 0;
}

.category-app-list.layout-grid5 .category-app-meta span:nth-child(n+3) {
    display: none;
}

.category-app-list.layout-grid5 .category-app-excerpt,
.category-app-list.layout-grid5 .category-app-btn {
    display: none;
}

.category-app-item {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #fff;
    transition: transform 0.3s ease;
}

.category-app-item:hover {
    transform: translateY(-5px);
}

.category-app-thumb img {
    width: 90px;
    height: 90px;
    border-radius: 18px;
    object-fit: cover;
}

.category-app-title {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.category-app-title a {
    transition: color 0.2s ease;
}

.category-app-title a:hover {
    color: var(--primary);
}

.category-app-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.category-app-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.meta-icon {
    width: 14px;
    height: 14px;
}

.meta-star {
    color: #ffa800;
    fill: #ffa800;
}

.category-app-excerpt {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.category-app-btn {
    background: var(--primary-light);
    color: var(--primary);
    padding: 9px 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.category-app-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.category-pagination {
    margin-top: 20px;
}

.category-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    margin-right: 8px;
    padding: 0 10px;
    border-radius: 8px;
    background: #f1f3f4;
    color: var(--text-secondary);
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.category-pagination .page-numbers.current,
.category-pagination .page-numbers:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.category-empty {
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 8px 0;
}

@media (max-width: 992px) {
    .category-page-layout {
        grid-template-columns: 1fr;
    }

    .category-sidebar {
        display: block;
    }

    .category-nav-list {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
    }

    .category-nav-item {
        min-width: 0;
    }

    .category-nav-name {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .category-app-list.layout-grid5 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .category-nav-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .tag-page .category-nav-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .category-nav-item {
        padding: 9px 10px;
        gap: 8px;
    }

    .category-nav-count {
        font-size: 0.75rem;
    }

    .category-header-actions {
        gap: 8px;
        flex-wrap: wrap;
    }

    .category-app-list.layout-list .category-app-item {
        grid-template-columns: 72px 1fr;
        gap: 12px;
    }

    .category-app-list.layout-list .category-app-thumb img {
        width: 72px;
        height: 72px;
        border-radius: 14px;
    }

    .category-app-list.layout-list .category-app-btn {
        grid-column: 1 / -1;
        text-align: center;
    }

    .category-app-list.layout-grid5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Search Page */
.search-page .search-results-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.search-page .search-title-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 0;
}

.search-page .search-title-section h1 {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.25;
    margin-bottom: 8px;
}

.search-page .search-query {
    color: var(--primary);
}

.search-page .search-count {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.search-page .results-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.search-page .search-item {
    display: grid;
    grid-template-columns: 90px 1fr auto;
    gap: 16px;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    background: #fff;
}

.search-page .search-item-left img {
    width: 90px;
    height: 90px;
    border-radius: 16px;
    object-fit: cover;
}

.search-page .search-item-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: inline-block;
    margin-bottom: 4px;
}

.search-page .search-item-title:hover {
    color: var(--primary);
}

.search-page .search-item-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.86rem;
    margin-bottom: 6px;
}

.search-page .search-item-rating {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #ffa800;
}

.search-page .search-item-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.search-page .search-item-right {
    display: flex;
    align-items: center;
}

.search-page .btn-download-search {
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.search-page .btn-download-search:hover {
    background: var(--primary);
    color: #fff;
}

.search-page .search-empty {
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 12px 2px;
}

.search-page .search-pagination {
    margin-top: 20px;
}

.search-page .search-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    margin-right: 8px;
    margin-bottom: 8px;
    padding: 0 10px;
    border-radius: 8px;
    background: #f1f3f4;
    color: var(--text-secondary);
}

.search-page .search-pagination .page-numbers.current,
.search-page .search-pagination .page-numbers:hover {
    background: var(--primary);
    color: #fff;
}

@media (max-width: 768px) {
    .search-page .search-title-section h1 {
        font-size: 1.35rem;
    }

    .search-page .search-item {
        grid-template-columns: 72px 1fr;
        gap: 12px;
    }

    .search-page .search-item-left img {
        width: 72px;
        height: 72px;
        border-radius: 14px;
    }

    .search-page .search-item-right {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

/* Default Page Template */
.apk-page {
    padding-top: 30px;
    padding-bottom: 40px;
}

.apk-page .apk-page-article {
    margin-bottom: 0;
}

.apk-page .apk-page-header {
    margin-bottom: 18px;
}

.apk-page .apk-page-title {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.25;
    margin-top: 10px;
    margin-bottom: 0;
}

.apk-page .apk-page-content {
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 1rem;
    word-break: break-word;
}

.apk-page .apk-page-content > *:first-child {
    margin-top: 0;
}

.apk-page .apk-page-content p,
.apk-page .apk-page-content ul,
.apk-page .apk-page-content ol,
.apk-page .apk-page-content blockquote,
.apk-page .apk-page-content pre {
    margin-bottom: 1em;
}

.apk-page .apk-page-content a {
    color: var(--primary);
}

.apk-page .apk-page-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
}

.apk-page .apk-page-content pre {
    overflow: auto;
    background: #f4f6f8;
    border-radius: 10px;
    padding: 12px 14px;
}

.apk-page .apk-page-content blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 12px;
    color: var(--text-secondary);
}

.apk-page .apk-page-links {
    margin-top: 14px;
    color: var(--text-secondary);
}

.apk-page .apk-page-empty {
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .apk-page .apk-page-title {
        font-size: 1.45rem;
    }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    header {
        background: #ffffff;
    }

    nav .primary-menu .sub-menu,
    nav .primary-menu .children {
        background: #ffffff;
    }
}

.back-to-top {
    position: fixed;
    right: 22px;
    bottom: 28px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.75);
    background: rgba(36, 161, 89, 0.92);
    box-shadow: 0 8px 20px rgba(36, 161, 89, 0.28);
    color: #fff;
    z-index: 1001;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(12px) scale(0.92);
    transition: opacity 0.24s ease, visibility 0.24s ease, transform 0.24s ease, background-color 0.24s ease, box-shadow 0.24s ease;
}

.back-to-top .back-to-top-arrow {
    width: 10px;
    height: 10px;
    border-left: 2px solid currentColor;
    border-top: 2px solid currentColor;
    transform: rotate(45deg) translateY(2px);
}

.back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.back-to-top:hover {
    background: var(--primary-dark);
    box-shadow: 0 10px 24px rgba(30, 138, 75, 0.36);
    transform: translateY(-2px) scale(1.03);
}

.back-to-top:active {
    transform: translateY(0) scale(0.98);
}

@media (max-width: 768px) {
    .back-to-top {
        right: 14px;
        bottom: 18px;
        width: 40px;
        height: 40px;
    }
}

body.download-modal-open {
    overflow: hidden;
}

.download-modal {
    position: fixed;
    inset: 0;
    z-index: 2200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.24s ease, visibility 0.24s ease;
}

.download-modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.download-modal-dialog {
    position: relative;
    width: min(520px, 100%);
    border-radius: 14px;
    background: #fff;
    border: 1px solid #e9edf2;
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.24);
    padding: 22px 20px 18px;
    transform: translateY(8px) scale(0.98);
    transition: transform 0.24s ease;
}

.download-modal.is-open .download-modal-dialog {
    transform: translateY(0) scale(1);
}

.download-modal-dialog.is-error {
    border-color: #ffd9d9;
}

.download-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: #f2f4f8;
    color: #4b5563;
    font-size: 1.2rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.download-modal-close:hover {
    background: #e7ebf1;
}

.download-modal-title {
    font-size: 1.05rem;
    margin-bottom: 10px;
    color: #111827;
}

.download-modal-message {
    margin: 0;
    color: #334155;
    font-size: 0.95rem;
    line-height: 1.55;
}

.download-modal-actions {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.download-modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
}

.download-modal-btn.primary {
    background: var(--primary);
    color: #fff;
}

.download-modal-btn.primary:hover {
    background: var(--primary-dark);
}

.download-modal-btn.secondary {
    background: #eef6f1;
    color: #1e8a4b;
    border: 1px solid #ccebd8;
}

.download-modal-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #475569;
    font-size: 0.9rem;
}

.download-modal-spinner {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 2px solid #c8d4e3;
    border-top-color: var(--primary);
    animation: apkDownloadModalSpin 0.9s linear infinite;
}

@keyframes apkDownloadModalSpin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 640px) {
    .download-modal {
        padding: 14px;
    }

    .download-modal-dialog {
        padding: 18px 16px 14px;
    }

    .download-modal-btn {
        width: 100%;
    }
}