/* Layout */
.container { max-width: var(--container); margin: 0 auto; padding: 0 1.25rem; }
.page-main { padding: 1.5rem 0 3rem; }

/* Header */
.site-header {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-sm);
}
.site-header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-logo {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.site-logo em { font-style: normal; color: var(--primary); }
.header-tools { display: flex; align-items: center; gap: 0.5rem; flex: 1; justify-content: flex-end; max-width: 520px; }
.header-select, .header-search-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
}
.header-select { min-width: 140px; }
.header-search-input { flex: 1; min-width: 0; }
.header-search-btn {
  width: 40px; height: 40px;
  border: none; border-radius: var(--radius-sm);
  background: var(--accent-gradient);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.menu-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text); }

/* App icon */
.app-icon {
  width: 56px; height: 56px;
  max-width: 56px; max-height: 56px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--surface-muted);
  flex-shrink: 0;
}
.app-icon-lg { width: 72px; height: 72px; max-width: 72px; max-height: 72px; border-radius: 16px; }
.app-icon-sm { width: 48px; height: 48px; max-width: 48px; max-height: 48px; border-radius: 12px; }
.app-icon-fallback {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.25rem;
  color: var(--primary); background: var(--primary-soft);
}

/* App card */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  transition: box-shadow 0.2s, transform 0.15s;
  position: relative;
}
.app-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
.app-card-name { font-size: 0.85rem; font-weight: 600; line-height: 1.3; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; width: 100%; }
.app-card-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; align-items: center; }
.app-card-meta .star { color: #fbbf24; }
.app-card-cat { font-size: 0.7rem; color: var(--primary); background: var(--primary-soft); padding: 0.15rem 0.5rem; border-radius: 999px; }
.app-card-rank {
  position: absolute; top: 0.5rem; left: 0.5rem;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--text); color: #fff;
  font-size: 0.65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.app-card-medal { position: absolute; top: 0.35rem; right: 0.35rem; font-size: 1rem; }

/* Category banners (home 2x2) */
.category-banner-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.category-banner {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  min-height: 140px;
  transition: box-shadow 0.2s;
}
.category-banner:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.category-banner-visual {
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; position: relative;
}
.category-banner-icons { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: center; }
.category-banner-icon-dot {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,0.25); border: 2px solid rgba(255,255,255,0.4);
}
.category-banner-body { padding: 1.25rem; display: flex; flex-direction: column; justify-content: center; }
.category-banner-title { font-size: 0.95rem; font-weight: 700; line-height: 1.35; color: var(--text); }

/* Top 10 rail */
.section-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 1rem; color: var(--text); }
.top10-rail {
  display: flex; gap: 1rem; overflow-x: auto;
  padding-bottom: 0.5rem; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.top10-item {
  flex: 0 0 108px; scroll-snap-align: start;
  text-align: center; text-decoration: none; color: inherit;
}
.top10-item:hover { text-decoration: none; }
.top10-rank { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); margin-bottom: 0.35rem; }
.top10-rank.medal-gold { color: #d97706; }
.top10-rank.medal-silver { color: #6b7280; }
.top10-rank.medal-bronze { color: #b45309; }
.top10-item .app-icon,
.top10-item img.app-icon {
  width: 72px; height: 72px;
  max-width: 72px; max-height: 72px;
  margin: 0 auto 0.35rem;
  border-radius: 16px;
}
.top10-name {
  font-size: 0.72rem; font-weight: 600; line-height: 1.2; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; padding: 0 0.15rem;
}

/* Category hero */
.category-hero {
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  color: #fff;
  margin-bottom: 1.5rem;
}
.category-hero h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.5rem; }
.category-hero p { opacity: 0.92; font-size: 0.95rem; max-width: 560px; }

/* Detail page */
.detail-layout { display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem; align-items: start; }
.detail-header-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.detail-header-row { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.detail-header-info { flex: 1; min-width: 200px; }
.detail-header-info h1 { font-size: 1.35rem; font-weight: 800; margin-bottom: 0.5rem; }
.category-pill {
  display: inline-block; font-size: 0.75rem; font-weight: 600;
  color: var(--primary); background: var(--primary-soft);
  padding: 0.2rem 0.65rem; border-radius: 999px; margin-bottom: 0.5rem;
}
.btn-download {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.65rem 1.75rem;
  background: var(--accent-gradient);
  color: #fff; font-weight: 700; font-size: 0.9rem;
  border: none; border-radius: var(--radius-sm);
  text-decoration: none; letter-spacing: 0.03em;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
}
.btn-download:hover { text-decoration: none; color: #fff; filter: brightness(1.05); }
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem; margin-top: 1rem;
  padding-top: 1rem; border-top: 1px solid var(--border);
}
.stat-item { text-align: center; }
.stat-value { font-size: 1rem; font-weight: 700; color: var(--text); }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.15rem; }
.stat-value .star { color: #fbbf24; }

.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.detail-panel h2 { font-size: 1rem; font-weight: 700; margin-bottom: 0.75rem; color: var(--text); }
.info-table { width: 100%; font-size: 0.875rem; }
.info-table td { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.info-table td:first-child { color: var(--text-muted); width: 40%; }

.screenshot-carousel {
  display: flex; gap: 0.75rem; overflow-x: auto;
  padding-bottom: 0.5rem; scroll-snap-type: x mandatory;
}
.screenshot-carousel img {
  height: 220px; width: auto; border-radius: var(--radius-sm);
  border: 1px solid var(--border); scroll-snap-align: start;
  background: var(--surface-muted);
}
.screenshot-placeholder {
  flex: 0 0 120px; height: 220px; border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #e5e7eb, #f3f4f6);
  border: 1px solid var(--border);
}

.desc-collapsible { position: relative; }
.desc-collapsible.collapsed .desc-body { max-height: 120px; overflow: hidden; }
.desc-collapsible.collapsed::after {
  content: ''; position: absolute; bottom: 2.5rem; left: 0; right: 0; height: 48px;
  background: linear-gradient(transparent, var(--surface));
}
.desc-toggle {
  display: inline-flex; align-items: center; gap: 0.35rem;
  margin-top: 0.75rem; padding: 0.4rem 1rem;
  border: 1px solid #fecaca; border-radius: 999px;
  background: #fff; color: var(--text); font-size: 0.85rem;
  cursor: pointer;
}

.sidebar-related { display: flex; flex-direction: column; gap: 0.75rem; }
.related-card {
  display: flex; gap: 0.75rem; align-items: center;
  padding: 0.75rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  text-decoration: none; color: inherit;
}
.related-card:hover { box-shadow: var(--shadow-sm); text-decoration: none; }
.related-card-info { flex: 1; min-width: 0; }
.related-card-name { font-size: 0.8rem; font-weight: 600; line-height: 1.25; }
.related-card-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.2rem; }

/* Ads */
.ad-label { font-size: 0.7rem; color: var(--text-light); text-align: center; margin-bottom: 0.35rem; text-transform: uppercase; letter-spacing: 0.06em; }
.ad-label:empty,
.ad-label.hidden { display: none; }
.ad-slot {
  background: var(--surface-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light); font-size: 0.75rem;
  margin: 1rem 0;
}

/* Footer */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 2.5rem 0 1.5rem;
  margin-top: 2rem;
}
.site-footer-about { max-width: 640px; margin-bottom: 1.5rem; }
.site-footer-about p { font-size: 0.875rem; color: var(--text-muted); line-height: 1.7; }
.site-footer-links { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; font-size: 0.85rem; }
.site-footer-links a { color: var(--text-muted); text-decoration: none; }
.site-footer-links a:hover { color: var(--primary); }
.footer-category-section { margin-bottom: 1.5rem; }
.footer-category-title { font-size: 1rem; font-weight: 700; margin-bottom: 0.75rem; padding-bottom: 0.35rem; border-bottom: 2px solid var(--primary); display: inline-block; }
.footer-app-row { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 0.5rem; }
.footer-app-chip {
  flex: 0 0 90px; text-align: center; text-decoration: none; color: inherit;
}
.footer-app-chip:hover { text-decoration: none; }
.footer-app-chip .app-icon-sm { margin: 0 auto 0.35rem; }
.footer-app-chip span { font-size: 0.7rem; font-weight: 600; display: block; line-height: 1.2; }
.footer-copy { font-size: 0.8rem; color: var(--text-light); text-align: center; padding-top: 1rem; border-top: 1px solid var(--border); }

/* Search results dropdown */
.search-results {
  position: absolute; top: 100%; right: 0; left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  max-height: 320px; overflow-y: auto; display: none; z-index: 300;
}
.search-results.open { display: block; }
.search-result-item {
  display: flex; gap: 0.75rem; align-items: center;
  padding: 0.65rem 0.85rem; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border);
}
.search-result-item:hover { background: var(--surface-muted); text-decoration: none; }
.header-search-wrap { position: relative; flex: 1; display: flex; gap: 0.5rem; min-width: 0; }

/* Legacy / tools pages */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.65rem 1.25rem; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem; border: none; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--accent-gradient); color: #fff; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.calc-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem; }
.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.form-row input { width: 100%; padding: 0.6rem 0.85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }

@media (max-width: 900px) {
  .detail-layout { grid-template-columns: 1fr; }
  .category-banner-grid { grid-template-columns: 1fr; }
  .category-banner { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .header-select { display: none; }
}
@media (max-width: 640px) {
  .menu-toggle { display: block; }
  .header-tools { max-width: none; }
}

/* Legacy: tools / blog / legal pages */
.page-title { font-size: 1.75rem; font-weight: 800; margin-bottom: 0.5rem; }
.page-desc { color: var(--text-muted); margin-bottom: 1.5rem; }
.page-header { margin-bottom: 1.5rem; }
.main { max-width: var(--container); margin: 0 auto; padding: 2rem 1.25rem; }
.scenario-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.scenario-btn { padding: 0.4rem 0.85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: 0.85rem; }
.result-banner { padding: 1rem; border-radius: var(--radius-sm); font-weight: 600; margin-bottom: 1rem; }
.result-banner.positive { background: #ecfdf5; color: #15803d; border: 1px solid #bbf7d0; }
.result-banner.negative { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.metric-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.metric-table td { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.metric-table td:first-child { color: var(--text-muted); }
.metric-table td:last-child { text-align: right; font-weight: 600; }
.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.blog-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem; text-decoration: none; color: inherit; }
.blog-card:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.blog-meta { font-size: 0.75rem; color: var(--text-muted); }
.footer { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.85rem; border-top: 1px solid var(--border); }
