:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f2f3f5;
  --border: #e3e4e8;
  --border-strong: #d2d4da;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --accent: #0a84ff;
  --accent-strong: #0071e3;
  --accent-soft: rgba(10, 132, 255, 0.14);
  --success: #1d8a45;
  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(17, 24, 39, 0.04), 0 10px 30px rgba(17, 24, 39, 0.06);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101013;
    --surface: #1a1a1e;
    --surface-2: #232329;
    --border: #2c2c33;
    --border-strong: #3a3a43;
    --text: #f5f5f7;
    --text-2: #a1a1aa;
    --text-3: #7c7c85;
    --accent: #409cff;
    --accent-strong: #6cb6ff;
    --accent-soft: rgba(64, 156, 255, 0.18);
    --success: #38b26a;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent-strong);
}

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.hero {
  padding: 44px 0 22px;
}

.hero h1 {
  font-size: clamp(28px, 4.4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.hero p {
  max-width: 640px;
  margin-top: 10px;
  color: var(--text-2);
  font-size: 17px;
}

.tool {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.search-form {
  display: flex;
  gap: 10px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
}

.search-input-wrap svg {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 18px;
  height: 18px;
  color: var(--text-3);
  pointer-events: none;
  transform: translateY(-50%);
}

#search-input {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#search-input::placeholder {
  color: var(--text-3);
}

#search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.btn {
  height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-primary:active {
  transform: translateY(1px);
}

.region {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.region-popular,
.region-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.region-list {
  margin-top: 8px;
}

.region-list[hidden] {
  display: none;
}

.region-error {
  color: var(--text-2);
  font-size: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.35;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.chip[aria-pressed="true"],
.chip[aria-pressed="true"]:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.chip-flag {
  font-size: 14px;
  line-height: 1;
}

.chip-toggle {
  min-width: 32px;
  justify-content: center;
  padding: 5px 9px;
  color: var(--text-2);
}

.chip-toggle svg {
  width: 12px;
  height: 12px;
  transition: transform 0.15s ease;
}

.chip-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.chip:focus-visible,
.btn:focus-visible,
.page-btn:focus-visible,
.copy-btn:focus-visible,
.app-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.results {
  margin: 26px 0 44px;
}

.results-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--text-2);
  font-size: 14px;
}

.results-summary strong {
  color: var(--text);
}

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

.app-card {
  display: flex;
  min-width: 0;
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.app-icon-wrap {
  flex: none;
}

.app-icon {
  display: block;
  width: 56px;
  height: 56px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='1.6'%3E%3Crect x='4' y='4' width='16' height='16' rx='4'/%3E%3C/svg%3E")
    center / 26px 26px no-repeat;
  object-fit: cover;
}

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

.app-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-genre {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
}

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

.bundle-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 4px 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.bundle-id {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
  user-select: all;
}

.copy-btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.copy-btn.copied,
.copy-btn.copied:hover {
  border-color: var(--success);
  background: var(--success);
  color: #ffffff;
}

.copy-btn svg {
  width: 13px;
  height: 13px;
}

.copy-helper {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: transparent;
  font-size: 16px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.app-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 16px;
  margin-top: 8px;
}

.app-link {
  color: var(--text-2);
  font-size: 12px;
  text-decoration: none;
}

.app-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

.page-btn {
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.page-btn:disabled {
  cursor: default;
  opacity: 0.42;
}

.page-status {
  min-width: 64px;
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
}

.state-card {
  padding: 28px 22px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.state-title {
  font-size: 16px;
  font-weight: 600;
}

.state-text {
  max-width: 560px;
  margin: 6px auto 0;
  color: var(--text-2);
  font-size: 14px;
}

.state-card .btn {
  height: 40px;
  margin-top: 16px;
  padding: 0 18px;
  font-size: 14px;
}

.skeleton-card {
  display: flex;
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

.skeleton-icon {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 12px;
}

.skeleton-lines {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 9px;
  padding-top: 4px;
}

.skeleton-line {
  height: 12px;
}

.w40 {
  width: 40%;
}

.w60 {
  width: 60%;
}

.w80 {
  width: 80%;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.site-footer {
  padding: 22px 0 30px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12.5px;
}

.site-footer p {
  max-width: 720px;
}

@media (max-width: 640px) {
  .hero {
    padding-top: 30px;
  }

  .hero p {
    font-size: 16px;
  }

  .tool {
    padding: 14px;
    border-radius: 16px;
  }

  .search-form {
    flex-direction: column;
  }

  .btn-primary {
    width: 100%;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
