/* ============================================
   StoreFront - App Store 地区切换工具
   Created by chenan
   ============================================ */

/* --- CSS Variables --- */
:root {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.72);
  --bg-card-hover: rgba(255, 255, 255, 0.92);
  --bg-nav: rgba(245, 245, 247, 0.8);
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border-color: rgba(0, 0, 0, 0.06);
  --border-card: rgba(0, 0, 0, 0.08);
  --accent-blue: #0A84FF;
  --accent-purple: #5E5CE6;
  --accent-pink: #FF375F;
  --accent-green: #30D158;
  --accent-orange: #FF9F0A;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.04), 0 0 1px rgba(0,0,0,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  --blob-1: rgba(10, 132, 255, 0.08);
  --blob-2: rgba(94, 92, 230, 0.06);
  --blob-3: rgba(255, 55, 95, 0.05);

  --search-bg: rgba(0, 0, 0, 0.04);
  --search-bg-focus: rgba(255, 255, 255, 0.95);
  --kbd-bg: rgba(0, 0, 0, 0.06);
  --kbd-text: #86868b;

  --region-header-bg: rgba(0, 0, 0, 0.02);
}

/* Dark theme */
[data-theme="dark"] {
  --bg-primary: #000000;
  --bg-secondary: #1c1c1e;
  --bg-card: rgba(44, 44, 46, 0.72);
  --bg-card-hover: rgba(58, 58, 60, 0.92);
  --bg-nav: rgba(0, 0, 0, 0.8);
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #6e6e73;
  --border-color: rgba(255, 255, 255, 0.06);
  --border-card: rgba(255, 255, 255, 0.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.4);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.2), 0 0 1px rgba(255,255,255,0.05);

  --blob-1: rgba(10, 132, 255, 0.12);
  --blob-2: rgba(94, 92, 230, 0.1);
  --blob-3: rgba(255, 55, 95, 0.08);

  --search-bg: rgba(255, 255, 255, 0.08);
  --search-bg-focus: rgba(44, 44, 46, 0.95);
  --kbd-bg: rgba(255, 255, 255, 0.1);
  --kbd-text: #6e6e73;

  --region-header-bg: rgba(255, 255, 255, 0.03);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'DM Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

/* --- Background Decoration --- */
.bg-decoration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: blobFloat 20s ease-in-out infinite;
}

.blob-1 {
  width: 600px;
  height: 600px;
  background: var(--blob-1);
  top: -200px;
  right: -100px;
  animation-delay: 0s;
}

.blob-2 {
  width: 500px;
  height: 500px;
  background: var(--blob-2);
  bottom: -150px;
  left: -100px;
  animation-delay: -7s;
}

.blob-3 {
  width: 400px;
  height: 400px;
  background: var(--blob-3);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
}

/* --- Navbar --- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  background: var(--bg-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-color);
}

.nav-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Language Switcher */
.lang-switcher {
  position: relative;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.lang-btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 140px;
  padding: 4px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition-fast);
  z-index: 1000;
  backdrop-filter: blur(20px);
}

.lang-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
}

.lang-option:hover {
  background: var(--search-bg);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--search-bg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--border-card);
  color: var(--text-primary);
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* --- Main --- */
.main {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  padding-top: 52px;
}

/* --- Hero --- */
.hero {
  text-align: center;
  padding: 60px 0 32px;
}

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 100px;
  background: var(--search-bg);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2px;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
  animation: fadeInUp 0.6s ease both;
}

.hero-title {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1.15;
  margin-bottom: 16px;
  animation: fadeInUp 0.6s ease 0.1s both;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 32px;
  line-height: 1.6;
  animation: fadeInUp 0.6s ease 0.2s both;
}

/* --- Search --- */
.search-container {
  max-width: 560px;
  margin: 0 auto 16px;
  animation: fadeInUp 0.6s ease 0.3s both;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  height: 48px;
  padding: 0 48px 0 48px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  background: var(--search-bg);
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: all var(--transition-normal);
  outline: none;
}

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

.search-input:focus {
  background: var(--search-bg-focus);
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.15);
}

.search-kbd {
  position: absolute;
  right: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--kbd-bg);
  color: var(--kbd-text);
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.search-input:focus ~ .search-kbd {
  opacity: 0;
}

/* App Search */
.app-search-container {
  max-width: 560px;
  margin: 0 auto 0;
  animation: fadeInUp 0.6s ease 0.35s both;
}

.app-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.app-search-box .search-input {
  padding-right: 110px;
}

.app-search-btn {
  position: absolute;
  right: 6px;
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.app-search-btn:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.app-search-btn:active {
  transform: scale(0.98);
}

.app-search-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* --- Stats Bar --- */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 0 8px;
  animation: fadeInUp 0.6s ease 0.4s both;
}

.stat-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.stat-number {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-blue);
}

.stat-label {
  font-size: 13px;
  color: var(--text-tertiary);
}

.stat-divider {
  width: 1px;
  height: 20px;
  background: var(--border-card);
}

/* --- App Results --- */
.app-results-section {
  margin: 32px 0;
  animation: fadeInUp 0.4s ease both;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.close-results {
  padding: 6px 14px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.close-results:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.app-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.app-result-card {
  display: flex;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-card);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-normal);
  animation: fadeInUp 0.4s ease both;
}

.app-result-card:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.app-icon {
  width: 56px;
  height: 56px;
  border-radius: 13px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-info {
  flex: 1;
  min-width: 0;
}

.app-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-developer {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-region-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  background: rgba(10, 132, 255, 0.1);
  color: var(--accent-blue);
  font-size: 11px;
  font-weight: 600;
}

.app-price {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.app-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-tertiary);
  font-size: 14px;
}

.app-loading .spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-card);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Regions --- */
.regions-container {
  padding-bottom: 80px;
}

.region-group {
  margin-bottom: 32px;
  animation: fadeInUp 0.5s ease both;
}

.region-group:nth-child(1) { animation-delay: 0.1s; }
.region-group:nth-child(2) { animation-delay: 0.15s; }
.region-group:nth-child(3) { animation-delay: 0.2s; }
.region-group:nth-child(4) { animation-delay: 0.25s; }
.region-group:nth-child(5) { animation-delay: 0.3s; }
.region-group:nth-child(6) { animation-delay: 0.35s; }

.region-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: var(--region-header-bg);
}

.region-emoji {
  font-size: 20px;
}

.region-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.region-count {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-left: auto;
}

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

.country-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-card);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
  width: 100%;
}

.country-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.05), rgba(94, 92, 230, 0.05));
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.country-card:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
  border-color: rgba(10, 132, 255, 0.2);
}

.country-card:hover::before {
  opacity: 1;
}

.country-card:active {
  transform: translateY(0);
}

.country-flag {
  font-size: 26px;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.country-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.country-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.country-code {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.country-arrow {
  color: var(--text-tertiary);
  opacity: 0;
  transform: translateX(-4px);
  transition: all var(--transition-normal);
  position: relative;
  z-index: 1;
}

.country-card:hover .country-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--accent-blue);
}

/* No results */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.no-results-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.no-results-text {
  font-size: 16px;
  font-weight: 500;
}

/* --- Footer --- */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 13px;
  border-top: 1px solid var(--border-color);
}

.footer-sub {
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.7;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .hero {
    padding: 40px 0 24px;
  }

  .hero-title {
    font-size: 28px;
    letter-spacing: -0.8px;
  }

  .hero-desc {
    font-size: 15px;
  }

  .country-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
  }

  .country-card {
    padding: 10px 12px;
  }

  .country-flag {
    font-size: 22px;
  }

  .country-name {
    font-size: 13px;
  }

  .app-results-grid {
    grid-template-columns: 1fr;
  }

  .app-search-btn {
    padding: 0 12px;
    font-size: 12px;
  }

  .app-search-box .search-input {
    padding-right: 96px;
  }
}

@media (max-width: 480px) {
  .nav-content {
    padding: 0 16px;
  }

  .main {
    padding: 0 16px;
    padding-top: 52px;
  }

  .country-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stats-bar {
    gap: 12px;
  }

  .stat-number {
    font-size: 18px;
  }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-card);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* --- Region Detail View --- */
.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 0 20px;
  flex-wrap: wrap;
  animation: fadeInUp 0.4s ease both;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.back-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.detail-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.detail-flag {
  font-size: 36px;
  line-height: 1;
}

.detail-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.detail-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.detail-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-switch-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
}

.detail-switch-link:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.detail-external-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--accent-blue);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.detail-external-link:hover {
  background: rgba(10, 132, 255, 0.1);
  border-color: var(--accent-blue);
}

/* Chart Tabs */
.chart-tabs {
  display: flex;
  gap: 8px;
  padding: 4px;
  margin-bottom: 24px;
  background: var(--search-bg);
  border-radius: var(--radius-md);
  width: fit-content;
  animation: fadeInUp 0.4s ease 0.1s both;
}

.chart-tab {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.chart-tab:hover {
  color: var(--text-primary);
}

.chart-tab.active {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.chart-tabs-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.chart-refresh-btn:hover {
  color: var(--accent-blue);
  border-color: var(--accent-blue);
  background: rgba(10, 132, 255, 0.05);
}

.chart-refresh-btn.refreshing svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.chart-note {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 20px;
  padding: 0 4px;
  animation: fadeInUp 0.4s ease 0.12s both;
}

/* Chart Content */
.chart-content {
  animation: fadeInUp 0.4s ease 0.15s both;
  padding-bottom: 40px;
}

.chart-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-app-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-card);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-normal);
  animation: fadeInUp 0.3s ease both;
}

.chart-app-item:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  border-color: rgba(10, 132, 255, 0.15);
}

.chart-app-rank {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-tertiary);
  min-width: 28px;
  text-align: center;
}

.chart-app-rank.top3 {
  color: var(--accent-blue);
  font-size: 18px;
}

.chart-app-icon {
  width: 56px;
  height: 56px;
  border-radius: 13px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.chart-app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chart-app-info {
  flex: 1;
  min-width: 0;
}

.chart-app-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-app-genre {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-app-developer {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-app-action {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chart-app-price {
  padding: 5px 14px;
  border-radius: 100px;
  background: rgba(10, 132, 255, 0.1);
  color: var(--accent-blue);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .detail-header {
    gap: 12px;
  }

  .detail-flag {
    font-size: 28px;
  }

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

  .detail-external-link {
    font-size: 12px;
    padding: 6px 12px;
  }

  .chart-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .chart-tab {
    padding: 6px 14px;
    font-size: 13px;
  }

  .chart-app-item {
    padding: 10px 12px;
    gap: 10px;
  }

  .chart-app-icon {
    width: 48px;
    height: 48px;
    border-radius: 11px;
  }

  .chart-app-name {
    font-size: 14px;
  }
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}
