:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --sponsored-bg: #fffbeb;
  --sponsored-border: #fef3c7;
  --sponsored-badge: #d97706;
  --sponsored-badge-bg: #fef3c7;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090d16;
    --surface: #131b2e;
    --surface-alt: #1e293b;
    --border: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #172554;
    --sponsored-bg: #291e0a;
    --sponsored-border: #452c08;
    --sponsored-badge: #fbbf24;
    --sponsored-badge-bg: #452c08;
    --success: #22c55e;
    --success-bg: #052e16;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 20px rgba(0,0,0,0.5);
  }
}

[data-theme="dark"] {
  --bg: #090d16;
  --surface: #131b2e;
  --surface-alt: #1e293b;
  --border: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #172554;
  --sponsored-bg: #291e0a;
  --sponsored-border: #452c08;
  --sponsored-badge: #fbbf24;
  --sponsored-badge-bg: #452c08;
  --success: #22c55e;
  --success-bg: #052e16;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.5);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Header & Nav */
.site-header {
  border-bottom: 1px solid var(--border);
  background-color: var(--surface);
  position: sticky;
  top: 0;
  z-index: 40;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
}
.brand-link span {
  color: var(--primary);
}
.brand-link:hover {
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.region-btn, .theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
}
.region-btn:hover, .theme-btn:hover {
  background: var(--border);
}

/* Region Selector Dropdown */
.region-dropdown {
  position: relative;
}
.region-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  width: 240px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  z-index: 50;
}
.region-menu.active {
  display: block;
}
.region-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  text-decoration: none;
  min-height: 38px;
}
.region-menu a:hover, .region-menu a.current {
  background: var(--primary-light);
  color: var(--primary);
}

/* Hero & Search Homepage */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
}
.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}
.hero-title span {
  color: var(--primary);
}
.hero-sub {
  color: var(--text-muted);
  max-width: 580px;
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

/* Search Form & Combobox */
.search-wrapper {
  position: relative;
  width: 100%;
  max-width: 650px;
}
.search-box {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 9999px;
  box-shadow: var(--shadow);
  padding: 0.35rem 0.5rem 0.35rem 1.25rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}
.search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.05rem;
  padding: 0.5rem 0.5rem 0.5rem 0;
  outline: none;
  min-height: 44px;
}
.search-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 9999px;
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  min-height: 44px;
  transition: background-color 0.15s;
}
.search-btn:hover {
  background: var(--primary-hover);
}

/* Autocomplete Suggestion Dropdown */
.suggestions-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  list-style: none;
  overflow: hidden;
  z-index: 60;
  display: none;
}
.suggestions-list.active {
  display: block;
}
.suggestion-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.95rem;
  min-height: 44px;
}
.suggestion-item:hover, .suggestion-item.selected {
  background: var(--primary-light);
  color: var(--primary);
}

/* Header Brand & Search Box */
.header-brand-logo {
  height: 32px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  display: block;
}
.header-search-wrap {
  flex: 1;
  max-width: 652px;
  position: relative;
}

/* Google-Style Sub Navigation Tabs */
.g-subnav {
  border-bottom: 1px solid var(--border);
  background-color: var(--surface);
  overflow-x: auto;
}
.g-subnav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}
.g-tabs {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-left: 172px;
}
@media (max-width: 768px) {
  .g-tabs {
    padding-left: 0;
    gap: 1rem;
  }
}
.g-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 0.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.g-tab:hover {
  color: var(--primary);
  text-decoration: none;
}
.g-tab.active {
  color: #1a73e8;
  border-bottom-color: #1a73e8;
  font-weight: 600;
}

/* Results Page Container & Left Alignment */
.results-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  width: 100%;
}
.results-inner-col {
  max-width: 652px;
  margin-left: 172px;
}
@media (max-width: 768px) {
  .results-inner-col {
    margin-left: 0;
    max-width: 100%;
  }
}

/* Google-Style Results Meta */
.g-results-meta {
  color: #70757a;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}
[data-theme="dark"] .g-results-meta {
  color: #9aa0a6;
}

/* Google-Style Did You Mean */
.g-did-you-mean {
  font-size: 1.05rem;
  color: #c5221f;
  margin-bottom: 1.25rem;
  line-height: 1.4;
}
.g-did-you-mean a {
  color: #1a0dab;
  font-weight: 500;
}
.g-did-you-mean a:hover {
  text-decoration: underline;
}
[data-theme="dark"] .g-did-you-mean {
  color: #f28b82;
}
[data-theme="dark"] .g-did-you-mean a {
  color: #8ab4f8;
}
.g-corrected-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 0.25rem;
}

/* Results Stream */
.results-stream {
  display: flex;
  flex-direction: column;
}

/* Google Search Result Item */
.g-result-item {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

/* Item Source / Favicon / Breadcrumb Row */
.g-item-source {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  line-height: 1.3;
}
.g-source-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-alt);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}
.g-source-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.g-source-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.g-source-name {
  color: #202124;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-theme="dark"] .g-source-name {
  color: #dadce0;
}
.g-source-url {
  color: #4d5156;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-theme="dark"] .g-source-url {
  color: #9aa0a6;
}

/* Result Title (Google Blue) */
.g-item-title {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  line-height: 1.35;
  font-weight: 400;
}
.g-item-title a {
  color: #1a0dab;
  text-decoration: none;
  cursor: pointer;
}
.g-item-title a:hover {
  text-decoration: underline;
}
.g-item-title a:visited {
  color: #681da8;
}
[data-theme="dark"] .g-item-title a {
  color: #8ab4f8;
}
[data-theme="dark"] .g-item-title a:visited {
  color: #c58af9;
}

/* Result Snippet */
.g-item-snippet {
  color: #4d5156;
  font-size: 0.875rem;
  line-height: 1.58;
  word-wrap: break-word;
  margin-bottom: 0.5rem;
}
[data-theme="dark"] .g-item-snippet {
  color: #bdc1c6;
}

/* Sitelinks / Action Pills */
.g-item-sitelinks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.g-sitelink-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-weight: 500;
}
.g-featured-badge {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}
[data-theme="dark"] .g-featured-badge {
  background: #172554;
  border-color: #1e40af;
  color: #93c5fd;
}
.g-sitelink-action {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8125rem;
  color: #1a0dab;
  font-weight: 500;
  text-decoration: none;
}
.g-sitelink-action:hover {
  text-decoration: underline;
}
[data-theme="dark"] .g-sitelink-action {
  color: #8ab4f8;
}

/* Sponsored Result (Google Ads Format) */
.g-sponsored-item {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem;
}
.g-sponsored-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: #202124;
}
[data-theme="dark"] .g-sponsored-tag {
  color: #dadce0;
}
.g-source-bullet {
  color: #70757a;
  font-size: 0.75rem;
}

/* Separator for other regions */
.g-other-regions-heading {
  margin: 1.5rem 0 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Legacy Card Support */
.store-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}
.store-card.sponsored {
  background: var(--sponsored-bg);
  border-color: var(--sponsored-border);
}
.store-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-muted);
}
.store-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
  font-size: 0.9rem;
}
.page-link:hover, .page-link.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  text-decoration: none;
}
.page-link.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Homepage Popular Stores Grid */
.home-section {
  max-width: 1100px;
  margin: 0 auto 3rem;
  padding: 0 1rem;
  width: 100%;
}
.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.popular-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.popular-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  min-height: 64px;
  transition: transform 0.15s, border-color 0.15s;
}
.popular-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  text-decoration: none;
}

/* Footer */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.5rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}
@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
  }
}
