/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f4f6f9; color: #222; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; }

/* ===== VARIABLES ===== */
:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --accent: #f57c00;
  --hot-color: #e53935;
  --card-bg: #fff;
  --border: #e0e6ef;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --shadow-hover: 0 6px 20px rgba(0,0,0,.14);
  --header-h: 60px;
}

/* ===== LAYOUT ===== */
.wrap { width: 100%; max-width: none; margin: 0 auto; padding: 0 clamp(12px, 2vw, 28px); }
.layout { display: grid; grid-template-columns: minmax(210px, 240px) minmax(0, 1fr) minmax(160px, 180px); gap: clamp(12px, 1.6vw, 22px); padding-top: 20px; padding-bottom: 32px; align-items: start; }
.layout--no-sidebar { grid-template-columns: 1fr 180px; }
.layout--no-right { grid-template-columns: 240px 1fr; }
.layout--no-sidebar.layout--no-right { grid-template-columns: 1fr; }

/* ===== RIGHT AD COLUMN ===== */
.ad-col { position: sticky; top: calc(var(--header-h) + 12px); display: flex; flex-direction: column; gap: 14px; }
.ad-slot--col { border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 280px; }
.ad-placeholder--sky { min-height: 600px; }
.ad-placeholder--half-sky { min-height: 280px; }

/* ===== HEADER ===== */
.header { background: var(--primary); color: #fff; height: var(--header-h); position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.header .wrap { display: flex; align-items: center; gap: 12px; height: 100%; }

.logo { display: flex; align-items: center; gap: 6px; font-size: 1.25rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.logo-icon { background: rgba(255,255,255,.2); border-radius: 8px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; overflow: hidden; }
.logo-image { width: 100%; height: 100%; object-fit: contain; display: block; }
.logo-icon--image { width: auto; min-width: 34px; max-width: 170px; padding: 0; background: transparent; }
.logo-icon--image .logo-image { width: auto; max-width: 170px; height: 38px; }
.logo-txt b { color: #ffd54f; }

.pf-nav { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.pf-a { color: rgba(255,255,255,.8); padding: 6px 12px; border-radius: 6px; font-size: .85rem; transition: background .15s, color .15s; white-space: nowrap; }
.pf-a:hover, .pf-a.active { background: rgba(255,255,255,.18); color: #fff; }
.pf-a.active { font-weight: 600; }

.hdr-search { display: flex; align-items: center; background: rgba(255,255,255,.15); border-radius: 8px; overflow: hidden; flex: 1; max-width: 320px; margin-left: auto; }
.hdr-search input { background: transparent; border: none; outline: none; color: #fff; padding: 7px 12px; width: 100%; font-size: .9rem; }
.hdr-search input::placeholder { color: rgba(255,255,255,.6); }
.hdr-search button { background: rgba(255,255,255,.2); border: none; color: #fff; padding: 0 12px; height: 36px; cursor: pointer; transition: background .15s; flex-shrink: 0; }
.hdr-search button:hover { background: rgba(255,255,255,.3); }

.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer; padding: 6px; }

/* ===== AD SLOTS ===== */
.ad-slot { width: 100%; overflow: hidden; text-align: center; }
.ad-slot--top { background: #e8edf5; border-bottom: 1px solid var(--border); }
.ad-slot--footer { background: #e8edf5; border-top: 1px solid var(--border); }
.ad-slot--mid { grid-column: 1 / -1; margin: 8px 0; }
.ad-slot--sidebar { border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 250px; }
.ad-slot--detail-top { margin: 16px 0; }
.ad-slot--after-hero { margin-bottom: 0; border-bottom: 1px solid var(--border); }
.ad-slot--pre-grid { margin-bottom: 16px; }
.ad-slot--pre-pag { margin-top: 24px; }

.ad-placeholder { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #e3eaf5 0%, #d0daea 100%); color: #90a4c0; font-size: .8rem; letter-spacing: .5px; text-transform: uppercase; min-height: 60px; border: 1px dashed #b0bfd5; }
.ad-placeholder--rect { min-height: 250px; }
.ad-slot > a { display: block; width: 100%; }
.ad-slot--sidebar > .ad-placeholder,
.ad-slot--col > .ad-placeholder { width: 100%; }
.ad-img { width: auto; max-width: 100%; height: auto; object-fit: contain; object-position: center center; margin: 0 auto; border: 1px solid var(--border); background: #e8edf5; }
/* ===== SIDEBAR ===== */
.sidebar { position: sticky; top: calc(var(--header-h) + 12px); }
.sidebar-section { background: var(--card-bg); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.sidebar-title { font-size: .85rem; font-weight: 700; color: #6b7c9a; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 10px; }
.sidebar-menu li + li { border-top: 1px solid #f0f3f8; }
.sidebar-menu a { display: flex; align-items: center; gap: 8px; padding: 9px 8px; border-radius: 8px; color: #334; font-size: .9rem; transition: background .15s, color .15s; }
.sidebar-menu a:hover, .sidebar-menu a.active { background: #e8f0fe; color: var(--primary); font-weight: 600; }
.sidebar-menu a i { width: 18px; text-align: center; }

/* ===== MAIN CONTENT ===== */
.main-content { min-width: 0; }
.page-head { margin-bottom: 16px; }
.page-title { font-size: 1.3rem; font-weight: 700; color: #1a2a4a; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-title .count { font-size: .85rem; font-weight: 400; color: #8a9ab5; }
.text-hot { color: var(--hot-color); }

/* ===== APP GRID ===== */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(120px, 12vw, 170px), 1fr)); gap: clamp(8px, 1vw, 14px); }

.app-card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; position: relative; transition: transform .2s, box-shadow .2s; }
.app-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

.app-card__img-wrap { display: block; aspect-ratio: 1; overflow: hidden; background: #f0f4fa; }
.app-card__img-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.app-card:hover .app-card__img-wrap img { transform: scale(1.06); }
.app-card__no-img { width: 100%; height: 100%; min-height: 100px; display: flex; align-items: center; justify-content: center; color: #bbb; font-size: 2rem; }

.app-card__body { padding: 5px 6px 7px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.app-card__name { font-size: .72rem; font-weight: 600; color: #1a2a4a; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.app-card__meta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 1px; }
.app-card__ver { display: none; }

.btn-detail { margin-top: auto; display: block; text-align: center; background: var(--primary); color: #fff; padding: 4px 6px; border-radius: 6px; font-size: .68rem; font-weight: 600; transition: background .15s; }
.btn-detail:hover { background: var(--primary-dark); }

/* ===== BADGES ===== */
.badge { display: inline-block; font-size: .65rem; font-weight: 700; padding: 2px 7px; border-radius: 20px; text-transform: uppercase; letter-spacing: .4px; }
.badge--hot { background: var(--hot-color); color: #fff; position: absolute; top: 8px; right: 8px; z-index: 2; }

.os-badge { display: inline-flex; align-items: center; gap: 3px; font-size: .62rem; font-weight: 600; padding: 1px 5px; border-radius: 20px; }
.os-badge--ios { background: #e8f0fe; color: #1565c0; }
.os-badge--android { background: #e6f7ee; color: #1b7a40; }
.meta-category { display: inline-flex; align-items: center; max-width: 100%; padding: 1px 5px; border-radius: 20px; background: #f1f5f9; color: #475569; font-size: .62rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta-size { display: none; }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 28px; flex-wrap: wrap; }
.pag-btn { display: flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 10px; border-radius: 8px; background: var(--card-bg); border: 1px solid var(--border); color: #334; font-size: .88rem; font-weight: 500; transition: background .15s, color .15s, border-color .15s; }
.pag-btn:hover { background: #e8f0fe; color: var(--primary); border-color: #a8c4f0; }
.pag-btn--current { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.pag-btn--disabled { opacity: .35; pointer-events: none; }
.pag-ellipsis { color: #aaa; padding: 0 4px; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; color: #8a9ab5; }
.empty-state i { font-size: 3rem; display: block; margin-bottom: 16px; }
.empty-state p { margin-bottom: 20px; font-size: 1.05rem; }

/* ===== BUTTONS ===== */
.btn-primary { display: inline-flex; align-items: center; gap: 7px; background: var(--primary); color: #fff; padding: 10px 22px; border-radius: 9px; font-weight: 600; font-size: .9rem; transition: background .15s; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-back { display: inline-flex; align-items: center; gap: 7px; background: #f0f4fa; color: #334; padding: 10px 18px; border-radius: 9px; font-weight: 500; font-size: .9rem; transition: background .15s; }
.btn-back:hover { background: #e0e8f5; }

/* ===== DETAIL PAGE ===== */
.breadcrumb { display: flex; align-items: center; gap: 6px; padding: 14px 0; font-size: .82rem; color: #8a9ab5; flex-wrap: wrap; }
.breadcrumb a { color: var(--primary); }
.breadcrumb a:hover { text-decoration: underline; }
.bc-sep { font-size: .65rem; color: #c0cad8; }

.detail-layout { display: grid; grid-template-columns: 1fr 280px; gap: 24px; align-items: start; padding-bottom: 32px; }

.detail-card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px; }
.detail-hero { display: flex; gap: 20px; padding: 24px; }

.detail-icon { width: 110px; height: 110px; flex-shrink: 0; border-radius: 22px; overflow: hidden; background: #f0f4fa; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.detail-icon img { width: 100%; height: 100%; object-fit: cover; }
.detail-icon-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; color: #bbb; }

.detail-info { flex: 1; min-width: 0; }
.detail-name { font-size: 1.3rem; font-weight: 700; color: #1a2a4a; margin-bottom: 8px; line-height: 1.3; }
.detail-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.detail-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-bottom: 16px; }
.detail-table th { text-align: left; color: #8a9ab5; font-weight: 500; padding: 4px 0; width: 130px; }
.detail-table td { color: #334; padding: 4px 0; }

.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-download { background: var(--accent); }
.btn-download:hover { background: #e65100; }

.detail-desc { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.detail-desc__title { font-size: 1rem; font-weight: 700; padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; color: #1a2a4a; }
.detail-desc__body { padding: 16px 20px; font-size: .9rem; line-height: 1.7; color: #334; }
.detail-desc__body img { max-width: 100%; border-radius: 8px; }
.detail-desc__body p { margin-bottom: 10px; }
.support-page { margin-bottom: 32px; }
.support-content h2,
.support-content h3 { color: #1a2a4a; margin: 18px 0 8px; line-height: 1.3; }
.support-content ul,
.support-content ol { list-style: disc; padding-left: 22px; margin: 10px 0 14px; }
.support-content ol { list-style: decimal; }
.support-content li { margin-bottom: 6px; }
.support-content a { color: var(--primary); font-weight: 600; }
.support-contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 18px; }
.support-contact-card { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: #f8fbff; color: #334; overflow-wrap: anywhere; }
.support-contact-card i { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: #e8f0fe; color: var(--primary); flex-shrink: 0; }
.support-contact-card strong { display: block; color: #1a2a4a; margin-bottom: 2px; }

.detail-sidebar { position: sticky; top: calc(var(--header-h) + 12px); }

/* ===== RELATED APPS ===== */
.related-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f0f3f8; font-size: .85rem; color: #334; transition: color .15s; }
.related-item:last-child { border-bottom: none; }
.related-item:hover { color: var(--primary); }
.related-item img { width: 40px; height: 40px; border-radius: 9px; object-fit: cover; background: #f0f4fa; flex-shrink: 0; }
.related-item__no-img { width: 40px; height: 40px; border-radius: 9px; background: #f0f4fa; display: flex; align-items: center; justify-content: center; color: #bbb; flex-shrink: 0; }
.related-item span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ===== FOOTER ===== */
.footer { background: #1a2a4a; color: #a0b0c8; padding: 32px 0 16px; margin-top: 20px; }
.footer-cols { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; margin-bottom: 24px; }
.footer-col .logo { color: #fff; margin-bottom: 10px; }
.footer-col p { font-size: .85rem; line-height: 1.6; }
.footer-col h4 { color: #fff; font-size: .9rem; margin-bottom: 10px; }
.footer-col ul li + li { margin-top: 6px; }
.footer-col ul a { font-size: .85rem; color: #a0b0c8; transition: color .15s; }
.footer-col ul a:hover { color: #fff; }
.footer-copy { border-top: 1px solid #2d4060; padding-top: 16px; font-size: .8rem; text-align: center; color: #6a8aaa; }


/* ===== DOWNLOAD BUTTON ===== */
.dl-btn { display: inline-flex; align-items: center; gap: 6px; background: #ffd54f; color: #1a2a4a; padding: 7px 14px; border-radius: 7px; font-weight: 700; font-size: .82rem; flex-shrink: 0; transition: background .15s; }
.dl-btn:hover { background: #ffca28; }

/* ===== BANNER ===== */
.banner-wrap { background: linear-gradient(135deg, #1565c0 0%, #0d47a1 60%, #283593 100%); padding: 28px 0; }
.banner-box { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.banner-left h2 { font-size: 1.9rem; font-weight: 800; color: #fff; line-height: 1.25; margin-bottom: 10px; }
.banner-left h2 span { color: #ffd54f; }
.banner-left p { color: rgba(255,255,255,.8); font-size: .92rem; margin-bottom: 18px; }
.btn-go { display: inline-flex; align-items: center; gap: 8px; background: #ffd54f; color: #1a2a4a; padding: 10px 24px; border-radius: 24px; font-weight: 700; font-size: .9rem; transition: background .15s, transform .15s; }
.btn-go:hover { background: #ffca28; transform: translateY(-1px); }
.banner-right { flex-shrink: 0; }
.icon-showcase { display: flex; flex-direction: column; gap: 8px; }
.ic-row { display: flex; gap: 8px; }
.ic-item { width: 50px; height: 50px; border-radius: 13px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.25rem; box-shadow: 0 2px 8px rgba(0,0,0,.22); transition: transform .2s; }
.ic-item:hover { transform: scale(1.1); }

/* ===== SIDEBAR — PLATFORM MINI BUTTONS ===== */
.pf-box { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 14px; }
.pf-mini { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; background: var(--card-bg); border-radius: 10px; border: 2px solid transparent; color: #6b7c9a; font-size: .76rem; font-weight: 600; box-shadow: var(--shadow); transition: background .15s, color .15s, border-color .15s; }
.pf-mini i { font-size: 1.15rem; }
.pf-mini span { max-width: 100%; line-height: 1.15; overflow-wrap: anywhere; }
.pf-mini:hover, .pf-mini.active { background: #e8f0fe; color: var(--primary); border-color: var(--primary); }

/* ===== SIDEBAR — CATEGORY GRID ===== */
.cat-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 4px; }
.cat-a { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 6px; border-radius: 10px; color: #fff; font-size: .73rem; font-weight: 600; text-align: center; transition: transform .15s, box-shadow .15s; box-shadow: 0 2px 6px rgba(0,0,0,.14); }
.cat-a i { font-size: 1.1rem; }
.cat-a:hover, .cat-a.active { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.22); }
.cat-a.active { outline: 2px solid #fff; outline-offset: -3px; }

/* ===== SECTION HEADINGS ===== */
.sec-hd { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; color: var(--hc, var(--primary)); margin-bottom: 14px; border-left: 4px solid var(--hc, var(--primary)); padding-left: 10px; }
.sec-more { margin-left: auto; font-size: .8rem; color: #8a9ab5; font-weight: 400; }
.sec-more:hover { color: var(--primary); }

/* ===== FOOTER — NEW DESIGN ===== */
.ft-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; margin-bottom: 32px; }
.ft-logo { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; font-weight: 700; color: #fff; margin-bottom: 12px; }
.ft-logo .logo-icon { background: rgba(255,255,255,.15); border-radius: 8px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.ft-logo .logo-icon--image { width: auto; height: auto; min-width: 0; max-width: 190px; background: transparent; border-radius: 0; }
.ft-logo .logo-icon--image .logo-image { width: auto; height: auto; max-width: 190px; max-height: 52px; object-fit: contain; }
.ft-col h5 { color: #fff; font-size: .86rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 14px; }
.ft-col a { display: block; color: #a0b0c8; font-size: .84rem; margin-bottom: 8px; transition: color .15s; overflow-wrap: anywhere; }
.ft-col a:hover { color: #fff; }
.ft-col a i { width: 16px; margin-right: 4px; }
.ft-about p { font-size: .84rem; line-height: 1.6; color: #a0b0c8; margin-bottom: 16px; }
.ft-social { display: flex; gap: 8px; }
.ft-social a { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: rgba(255,255,255,.1); border-radius: 50%; color: #fff; font-size: .95rem; margin-bottom: 0; transition: background .15s; }
.ft-social a:hover { background: rgba(255,255,255,.25); }
.ft-bottom { border-top: 1px solid #2d4060; padding: 16px 0; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: .8rem; color: #6a8aaa; }
.ft-bottom > span { min-width: 0; overflow-wrap: anywhere; }
.ft-badges { display: flex; gap: 8px; }
.ft-badge { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.07); padding: 6px 12px; border-radius: 6px; font-size: .8rem; color: #a0b0c8; border: 1px solid rgba(255,255,255,.12); }

/* ===== WIDE SCREENS ===== */
@media (min-width: 1700px) {
  .layout { grid-template-columns: 260px 1fr 200px; }
  .layout--no-sidebar { grid-template-columns: 1fr 200px; }
  .layout--no-right { grid-template-columns: 260px 1fr; }
  .layout--no-sidebar.layout--no-right { grid-template-columns: 1fr; }
}

/* ===== ≤1280px: hide right ad column ===== */
@media (max-width: 1280px) {
  .layout { grid-template-columns: 220px 1fr; }
  .layout--no-sidebar,
  .layout--no-sidebar.layout--no-right { grid-template-columns: 1fr; }
  .layout--no-right { grid-template-columns: 220px 1fr; }
  .ad-col { display: none; }
}

/* ===== ≤1024px: tablet ===== */
@media (max-width: 1024px) {
  .app-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .footer-cols { grid-template-columns: 1fr 1fr; }
  .footer-cols .footer-col:first-child { grid-column: 1 / -1; }
  .ft-grid { grid-template-columns: 1fr 1fr; }
  .ft-grid .ft-col:first-child { grid-column: 1 / -1; }
  .banner-left h2 { font-size: 1.5rem; }
  .ic-item { width: 44px; height: 44px; font-size: 1.1rem; }
}

/* ===== ≤900px: sidebar collapses to compact horizontal strips ===== */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-top: 12px;
  }
  .sidebar { position: static; }
  .ad-col { display: none; }

  /* pf-box: 4 equal columns in one row */
  .pf-box { grid-template-columns: repeat(4, 1fr); margin-bottom: 8px; }
  .pf-mini { padding: 8px 4px; font-size: .72rem; }
  .pf-mini i { font-size: 1rem; }

  /* cat-list: single horizontal scrollable row */
  .cat-list {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: 6px;
    padding-bottom: 6px;
    scrollbar-width: none;
  }
  .cat-list::-webkit-scrollbar { display: none; }
  .cat-a {
    flex-direction: row;
    flex-shrink: 0;
    padding: 7px 13px;
    border-radius: 24px;
    font-size: .76rem;
    gap: 5px;
  }

  /* hide sidebar ad on mobile — saves a lot of space */
  .ad-slot--sidebar { display: none; }

  /* app grid fills full width */
  .app-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }

  /* detail page */
  .detail-layout { grid-template-columns: 1fr; }
  .detail-sidebar { position: static; }
}

/* ===== ≤640px: phone ===== */
@media (max-width: 640px) {
  :root { --header-h: 52px; }
  .wrap { padding: 0 12px; }

  /* header: hide Download button, hamburger shows */
  .header .dl-btn { display: none; }
  .logo-txt { font-size: .95rem; }
  .hdr-search { max-width: none; flex: 1; }
  .pf-nav {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0;
    background: var(--primary-dark);
    flex-direction: column;
    align-items: stretch;
    padding: 8px 12px;
    gap: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    z-index: 99;
  }
  .pf-nav.open { display: flex; }
  .pf-a { border-radius: 0; padding: 11px 12px; border-bottom: 1px solid rgba(255,255,255,.1); }
  .nav-toggle { display: flex; align-items: center; justify-content: center; }

  /* banner */
  .banner-wrap { padding: 14px 0; }
  .banner-right { display: none; }
  .banner-left h2 { font-size: 1.15rem; margin-bottom: 6px; }
  .banner-left p { font-size: .82rem; margin-bottom: 12px; }
  .btn-go { padding: 8px 18px; font-size: .82rem; }

  /* app grid: 4 cols on standard phones */
  .app-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }

  /* app card body slightly tighter */
  .app-card__body { padding: 4px 5px 6px; }
  .btn-detail { padding: 3px 5px; font-size: .65rem; }

  /* detail */
  .detail-hero { flex-direction: column; padding: 14px; gap: 12px; }
  .detail-icon { width: 76px; height: 76px; }
  .detail-name { font-size: 1.05rem; }
  .detail-table th { width: 90px; }

  /* footer */
  .ft-grid { grid-template-columns: 1fr; }
  .ft-bottom { flex-direction: column; text-align: center; }
  .footer-cols { grid-template-columns: 1fr; }

  /* pagination */
  .pagination { gap: 4px; margin-top: 16px; }
  .pag-btn { min-width: 32px; height: 32px; font-size: .8rem; }
}

/* ===== ≤400px: small phone ===== */
@media (max-width: 400px) {
  .wrap { padding: 0 8px; }
  /* 3 columns on very narrow screens */
  .app-grid { grid-template-columns: repeat(3, 1fr); gap: 5px; }
  /* hide logo text, keep icon */
  .logo-txt { display: none; }
}

/* ===== RESPONSIVE OVERRIDES: BOOTSTRAP-LIKE FLUID VIEW ===== */
@media (min-width: 1400px) {
  .wrap { max-width: 1520px; }
  .app-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 1199px) {
  .layout,
  .layout--no-right {
    grid-template-columns: minmax(190px, 220px) minmax(0, 1fr);
  }

  .layout--no-sidebar,
  .layout--no-sidebar.layout--no-right {
    grid-template-columns: minmax(0, 1fr);
  }

  .ad-col { display: none; }
  .app-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
}

@media (max-width: 991px) {
  .layout,
  .layout--no-sidebar,
  .layout--no-right,
  .layout--no-sidebar.layout--no-right,
  .detail-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar,
  .detail-sidebar {
    position: static;
  }

  .pf-box {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .cat-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scrollbar-width: none;
  }

  .cat-list::-webkit-scrollbar { display: none; }
  .cat-a {
    flex: 0 0 auto;
    min-width: 116px;
    flex-direction: row;
    justify-content: center;
    border-radius: 999px;
    padding: 9px 13px;
  }

  .ad-slot--sidebar {
    display: none;
  }

  .banner-box {
    align-items: flex-start;
  }

  .banner-right {
    transform: scale(.9);
    transform-origin: right center;
  }

  .ft-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ft-about {
    grid-column: 1 / -1;
  }
}

@media (max-width: 767px) {
  :root { --header-h: 56px; }

  body {
    font-size: 14px;
  }

  .wrap {
    padding-left: 12px;
    padding-right: 12px;
  }

  .header {
    height: auto;
    min-height: var(--header-h);
  }

  .header .wrap {
    position: relative;
    height: auto;
    min-height: var(--header-h);
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .logo {
    min-width: 0;
    max-width: calc(100% - 48px);
  }

  .logo-icon--image .logo-image {
    max-width: 132px;
    height: 34px;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
  }

  .pf-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 12px;
    right: 12px;
    z-index: 110;
    margin: 0;
    padding: 8px;
    border-radius: 0 0 10px 10px;
    background: var(--primary-dark);
    box-shadow: 0 10px 24px rgba(0,0,0,.25);
  }

  .pf-nav.open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .pf-a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border: 0;
    border-radius: 8px;
    background: rgba(255,255,255,.08);
  }

  .hdr-search {
    order: 3;
    flex: 1 0 100%;
    max-width: none;
    margin-left: 0;
  }

  .header .dl-btn {
    display: none;
  }

  .ad-slot--top,
  .ad-slot--footer,
  .ad-slot--after-hero,
  .ad-slot--pre-pag,
  .ad-slot--detail-top {
    padding: 0;
  }

  .ad-img {
    width: 100%;
    max-height: 140px;
    object-fit: contain;
  }

  .banner-wrap {
    padding: 18px 0;
  }

  .banner-box {
    display: block;
  }

  .banner-right {
    display: none;
  }

  .banner-left h2 {
    font-size: 1.35rem;
  }

  .banner-left p {
    max-width: 42rem;
  }

  .layout {
    gap: 12px;
    padding-top: 12px;
  }

  .pf-box {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
  }

  .pf-mini {
    min-height: 54px;
    padding: 8px 4px;
    font-size: .72rem;
  }

  .cat-a {
    min-width: 102px;
    max-width: 160px;
    white-space: nowrap;
  }

  .page-head {
    margin-bottom: 12px;
  }

  .page-title {
    font-size: 1.1rem;
  }

  .app-grid {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 10px;
  }

  .app-card__name {
    font-size: .8rem;
    -webkit-line-clamp: 2;
    min-height: 2.08em;
  }

  .app-card__body {
    padding: 8px;
    gap: 5px;
  }

  .btn-detail {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
  }

  .detail-hero {
    flex-direction: row;
    align-items: flex-start;
    padding: 16px;
  }

  .detail-icon {
    width: 82px;
    height: 82px;
    border-radius: 18px;
  }

  .detail-name {
    font-size: 1.15rem;
  }

  .detail-table th {
    width: 88px;
  }

  .detail-actions > a {
    flex: 1 1 150px;
    justify-content: center;
  }

  .detail-desc__title {
    padding: 12px 14px;
  }

  .detail-desc__body {
    padding: 14px;
    overflow-wrap: anywhere;
  }

  .support-contact-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .ft-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 14px;
    row-gap: 22px;
    margin-bottom: 20px;
  }

  .ft-about {
    grid-column: 1 / -1;
    text-align: center;
  }

  .ft-logo,
  .ft-social {
    justify-content: center;
  }

  .ft-about p {
    max-width: 38rem;
    margin-left: auto;
    margin-right: auto;
  }

  .ft-col h5 {
    margin-bottom: 8px;
    font-size: .78rem;
  }

  .ft-col a {
    min-height: 34px;
    margin-bottom: 4px;
    padding: 7px 0;
    line-height: 1.25;
  }

  .ft-bottom {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 12px;
    padding: 14px 0 0;
  }
}

@media (max-width: 575px) {
  .wrap {
    padding-left: 10px;
    padding-right: 10px;
  }

  .app-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .app-card {
    border-radius: 10px;
  }

  .badge--hot {
    top: 6px;
    right: 6px;
  }

  .detail-hero {
    flex-direction: column;
  }

  .detail-icon {
    width: 90px;
    height: 90px;
  }

  .breadcrumb {
    padding: 10px 0;
  }

  .pagination {
    gap: 4px;
  }

  .pag-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
  }

  .ft-badges {
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    gap: 6px;
  }

  .ft-badge {
    flex: 1 1 130px;
    justify-content: center;
    max-width: 180px;
    padding: 8px 10px;
  }
}

@media (max-width: 360px) {
  .app-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .pf-box {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ft-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .ft-col {
    text-align: center;
  }

  .ft-col a {
    min-height: 32px;
  }
}

/* Desktop fluid layout: Bootstrap-like resizing for wide screens. */
@media (min-width: 992px) {
  .wrap {
    max-width: none;
    padding-left: clamp(16px, 2vw, 40px);
    padding-right: clamp(16px, 2vw, 40px);
  }

  .app-grid {
    grid-template-columns: repeat(auto-fit, minmax(clamp(118px, 7.5vw, 150px), 1fr));
    gap: clamp(10px, .85vw, 16px);
  }
}

@media (min-width: 1281px) {
  .layout {
    grid-template-columns:
      clamp(210px, 14vw, 280px)
      minmax(0, 1fr)
      clamp(160px, 11vw, 220px);
    gap: clamp(12px, 1.2vw, 24px);
  }

  .layout--no-sidebar { grid-template-columns: minmax(0, 1fr) clamp(160px, 11vw, 220px); }
  .layout--no-right { grid-template-columns: clamp(210px, 14vw, 280px) minmax(0, 1fr); }
  .layout--no-sidebar.layout--no-right { grid-template-columns: minmax(0, 1fr); }
}

@media (min-width: 1400px) {
  .wrap { max-width: none; }
  .app-grid { grid-template-columns: repeat(auto-fit, minmax(clamp(112px, 6.5vw, 142px), 1fr)); }
}

@media (min-width: 1700px) {
  .wrap { max-width: none; }
  .app-grid { grid-template-columns: repeat(auto-fit, minmax(clamp(108px, 5.7vw, 136px), 1fr)); }
}

@media (min-width: 2200px) {
  .app-grid { grid-template-columns: repeat(auto-fit, minmax(clamp(104px, 5vw, 128px), 1fr)); }
}

/* ===== EDGE-ALIGNED FLUID INDEX LAYOUT ===== */
.wrap {
  max-width: none !important;
}

.ad-slot--top .ad-img,
.ad-slot--footer .ad-img,
.ad-slot--after-hero .ad-img,
.ad-slot--pre-pag .ad-img,
.ad-slot--detail-top .ad-img {
  width: 100%;
  max-width: none;
  border-left: 0;
  border-right: 0;
}

/* ===== HEADER AUTH BUTTONS ===== */
.hdr-auth { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.hdr-auth-link { display: inline-flex; align-items: center; gap: 5px; padding: 6px 13px; border-radius: 6px; font-size: .82rem; font-weight: 600; color: rgba(255,255,255,.85); transition: background .15s, color .15s; white-space: nowrap; }
.hdr-auth-link:hover { background: rgba(255,255,255,.15); color: #fff; }
.hdr-auth-link--reg { background: rgba(255,255,255,.15); color: #fff; }
.hdr-auth-link--reg:hover { background: rgba(255,255,255,.28); }

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: calc(100vh - var(--header-h) - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  background: linear-gradient(135deg, #e8eef8 0%, #f4f6f9 60%, #e3eaf5 100%);
}

.auth-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(21,101,192,.13);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.auth-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary) 0%, #1976d2 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  color: #fff;
  margin: 0 auto 18px;
  box-shadow: 0 4px 16px rgba(21,101,192,.25);
}

.auth-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: #1a2a4a;
  margin-bottom: 6px;
}

.auth-sub {
  color: #6b7c9a;
  font-size: .9rem;
  margin-bottom: 24px;
}

.auth-form { text-align: left; }

.auth-field {
  margin-bottom: 16px;
}

.auth-field label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: #4a5a7a;
  margin-bottom: 6px;
}

.auth-field label i {
  color: var(--primary);
  width: 14px;
}

.auth-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .93rem;
  color: #222;
  background: #f8fafc;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.auth-field input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(21,101,192,.1);
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: 9px;
  font-size: .93rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s, box-shadow .15s;
  text-decoration: none;
}

.auth-btn--primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 12px rgba(21,101,192,.3);
}

.auth-btn--primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 5px 18px rgba(21,101,192,.4);
  transform: translateY(-1px);
}

.auth-btn--ghost {
  background: #f0f3fa;
  color: #4a5a7a;
}

.auth-btn--ghost:hover {
  background: #e0e8f5;
}

.auth-btn--full {
  width: 100%;
  margin-top: 6px;
}

.auth-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 10px;
  font-size: .9rem;
  line-height: 1.5;
  margin-bottom: 20px;
  text-align: left;
}

.auth-alert i { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

.auth-alert--success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}

.auth-alert--error {
  background: #fdecea;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

.auth-alert--pending {
  background: #fff8e1;
  color: #e65100;
  border: 1px solid #ffcc02;
}

.auth-switch {
  margin-top: 22px;
  font-size: .88rem;
  color: #6b7c9a;
  text-align: center;
}

.auth-switch a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

.auth-switch a:hover { color: var(--primary-dark); }

@media (max-width: 767px) {
  .hdr-auth { display: none; }
  .auth-card { padding: 28px 20px; }
  .auth-title { font-size: 1.25rem; }
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 16px; border-radius: 14px; }
}

.ad-slot--top .ad-img,
.ad-slot--after-hero .ad-img,
.ad-slot--footer .ad-img {
  object-fit: cover;
}

.ad-slot--top > a,
.ad-slot--footer > a,
.ad-slot--after-hero > a,
.ad-slot--pre-pag > a,
.ad-slot--detail-top > a {
  width: 100%;
}

@media (min-width: 992px) {
  .layout.wrap {
    max-width: none;
    padding-left: clamp(6px, .75vw, 14px);
    padding-right: clamp(6px, .75vw, 14px);
  }

  .layout {
    gap: clamp(10px, 1vw, 18px);
  }

  .sidebar {
    justify-self: start;
    width: 100%;
  }

  .main-content {
    width: 100%;
    min-width: 0;
  }

  .ad-col {
    justify-self: end;
    width: 100%;
  }

  .app-grid {
    grid-template-columns: repeat(auto-fill, minmax(clamp(112px, 7vw, 148px), 1fr));
    gap: clamp(8px, .8vw, 14px);
  }
}

@media (min-width: 1200px) {
  .layout {
    grid-template-columns:
      clamp(210px, 13vw, 260px)
      minmax(0, 1fr)
      clamp(160px, 10vw, 210px);
  }

  .layout--no-sidebar {
    grid-template-columns: minmax(0, 1fr) clamp(160px, 10vw, 210px);
  }

  .layout--no-right {
    grid-template-columns: clamp(210px, 13vw, 260px) minmax(0, 1fr);
  }

  .layout--no-sidebar.layout--no-right {
    grid-template-columns: minmax(0, 1fr);
  }

  .ad-col {
    display: flex;
  }
}

@media (min-width: 1600px) {
  .layout {
    grid-template-columns:
      clamp(220px, 12vw, 280px)
      minmax(0, 1fr)
      clamp(170px, 9vw, 230px);
  }

  .layout--no-sidebar {
    grid-template-columns: minmax(0, 1fr) clamp(170px, 9vw, 230px);
  }

  .layout--no-right {
    grid-template-columns: clamp(220px, 12vw, 280px) minmax(0, 1fr);
  }

  .app-grid {
    grid-template-columns: repeat(auto-fill, minmax(clamp(108px, 5.8vw, 138px), 1fr));
  }
}

@media (min-width: 2200px) {
  .layout {
    grid-template-columns:
      clamp(230px, 11vw, 300px)
      minmax(0, 1fr)
      clamp(180px, 8vw, 240px);
  }

  .app-grid {
    grid-template-columns: repeat(auto-fill, minmax(clamp(104px, 4.8vw, 128px), 1fr));
  }
}
