/* ========== Header ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.menu-btn:hover {
  background: var(--hover);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-secondary);
}

.logo-mark {
  width: 28px;
  height: 28px;
}

.search-wrap {
  flex: 1 1 0;
  min-width: 0;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}

.search-wrap input {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 48px;
  padding: 0 48px 0 20px;
  border: none;
  border-radius: 8px;
  background: var(--hover);
  font-size: 16px;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

.search-wrap input::placeholder {
  color: var(--text-muted);
}

.search-wrap .search-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.icon-btn:hover {
  background: var(--hover);
}

.avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1a73e8;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  overflow: hidden;
  padding: 0;
  border: none;
  cursor: pointer;
}

.avatar-btn.has-image {
  background: transparent;
}

.avatar-btn .avatar-img,
.avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* ========== Profile dropdown ========== */
.profile-menu {
  position: relative;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 300px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  z-index: 150;
  padding: 8px 0;
  overflow: hidden;
}

.profile-dropdown-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 14px;
}

.profile-dropdown-avatar {
  margin: 0;
  width: 40px;
  height: 40px;
  font-size: 16px;
  pointer-events: none;
}

.profile-name {
  font-size: 14px;
  font-weight: 500;
}

.profile-email {
  font-size: 12px;
  color: var(--text-secondary);
}

.profile-item {
  display: block;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
}

.profile-item:hover {
  background: var(--hover);
}

/* ========== Bottom nav (mobile) ========== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  z-index: 120;
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  min-width: 0;
}

.bottom-nav-item svg {
  width: 24px;
  height: 24px;
}

.bottom-nav-item.active {
  color: var(--play-green);
}

.bottom-nav-item:hover {
  background: var(--hover);
}

.card-link {
  color: inherit;
  text-decoration: none;
}

a.btn-install {
  display: inline-block;
  text-align: center;
}

a.chart-row {
  display: flex;
}

/* ========== Footer ========== */
.category-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
}

.category-nav-inner {
  display: flex;
  gap: 8px;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: var(--nav-h);
  align-items: flex-end;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-nav-inner::-webkit-scrollbar {
  display: none;
}

.cat-link {
  padding: 12px 16px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color var(--transition);
}

.cat-link:hover {
  color: var(--text);
}

.cat-link.active {
  color: var(--play-green);
  border-bottom-color: var(--play-green);
}

.cat-link.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* ========== Sidebar drawer ========== */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-w);
  max-width: 90vw;
  height: 100%;
  background: var(--surface);
  z-index: 210;
  transform: translateX(100%);
  transition: transform var(--transition);
  display: flex;
  flex-direction: column;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.drawer-nav {
  padding: 8px 0;
  overflow-y: auto;
  flex: 1;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  font-size: 14px;
  color: var(--text);
  transition: background var(--transition);
}

.drawer-item:hover {
  background: var(--hover);
}

.drawer-item svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.drawer-divider {
  height: 1px;
  background: var(--border-light);
  margin: 8px 16px;
}

.drawer-footer {
  padding: 16px 24px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
}

.drawer-footer a {
  color: var(--text-secondary);
}

.drawer-footer a:hover {
  text-decoration: underline;
}

/* ========== Main ========== */
.main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px 24px 48px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.section {
  margin-bottom: 40px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.section-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.section-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--play-green);
  white-space: nowrap;
}

.section-link:hover {
  text-decoration: underline;
}

/* ========== Footer ========== */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  padding: 40px 24px 32px;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
  margin-bottom: 32px;
}

.footer-col h4 {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--text);
}

.footer-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-menu li {
  margin: 0;
  padding: 0;
}

.footer-col a {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
}

.footer-col a:hover {
  color: var(--text);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-muted);
}

.footer-bottom-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-bottom-links a:hover {
  color: var(--text);
}

.locale-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
}

.locale-btn:hover {
  background: var(--hover);
}

/* ========== Responsive layout ========== */
@media (max-width: 900px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .search-wrap {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .header-inner {
    padding: 0 12px;
    gap: 8px;
  }

  .logo span {
    display: none;
  }

  .search-wrap input {
    height: 40px;
    font-size: 14px;
    padding: 0 40px 0 12px;
  }

  .main {
    padding: 12px 12px 32px;
  }

  .category-nav-inner {
    padding: 0 12px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .section-title {
    font-size: 18px;
  }

  .bottom-nav {
    display: flex;
  }

  body.has-bottom-nav .main,
  body.has-bottom-nav .site-footer,
  body.has-bottom-nav .detail-page {
    padding-bottom: 88px;
  }

  body.has-bottom-nav .site-footer {
    padding-bottom: 96px;
  }

  .menu-btn {
    display: none;
  }
}