.page {
  z-index: 1;
  max-width: min(1180px, 94vw);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
  position: relative;
}

.search-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.page-title {
  font-family: var(--font-ui);
  letter-spacing: -.02em;
  margin-bottom: .5rem;
  font-size: max(1.8rem, min(4vw, 2.5rem));
  font-weight: 700;
}

.page-subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: .95rem;
}

.search-bar {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  flex: auto;
  gap: .5rem;
  min-width: 0;
  margin-bottom: 2.5rem;
  padding: .5rem;
  transition: all .3s;
  display: flex;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}

.search-bar:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 10px 40px var(--accent-primary-glow);
}

.search-input {
  color: var(--text-primary);
  font-family: var(--font-ui);
  background: none;
  border: none;
  outline: none;
  flex: 1;
  padding: .85rem 1.5rem;
  font-size: 1.05rem;
}

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

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

.btn-search {
  background: var(--accent-solid, #7c3aed);
  color: #fff;
  cursor: pointer;
  border: none;
  border-radius: 100px;
  padding: .85rem 1.5rem;
  font-weight: 700;
  transition: all .3s;
}

.btn-search:hover {
  transform: scale(1.05);
}

@media (max-width: 480px) {
  .search-input {
    min-width: 0;
    padding: .85rem .75rem;
    font-size: .95rem;
  }

  .btn-search {
    text-indent: -999px;
    width: 2.6rem;
    padding: .85rem;
    position: relative;
    overflow: hidden;
  }

  .btn-search:after {
    content: "🔍";
    text-indent: 0;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    display: flex;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
  }
}

.cat-tabs {
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.5rem;
  display: flex;
}

.cat-tab {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 100px;
  padding: .45rem 1rem;
  font-size: .85rem;
  font-weight: 600;
  transition: all .2s;
}

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

.cat-tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.sort-tabs {
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
  display: flex;
}

.sort-tab {
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  color: var(--text-secondary);
  background: none;
  border-radius: 100px;
  padding: .35rem .85rem;
  font-size: .8rem;
  font-weight: 600;
  transition: all .2s;
}

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

.sort-tab.active {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.results-grid {
  flex-direction: column;
  gap: .75rem;
  display: flex;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  -webkit-backdrop-filter: blur(16px);
  cursor: pointer;
  color: inherit;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  text-decoration: none;
  transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s, border-color .2s;
  display: flex;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2), inset -1px -1px 4px rgba(0, 0, 0, .15), inset 1px 1px 4px rgba(255, 255, 255, .06);
}

.result-card:hover {
  border-color: rgba(255, 45, 120, .35);
  transform: translateX(5px) scale(1.005);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .28), 0 0 20px rgba(255, 45, 120, .1), inset -1px -1px 4px rgba(0, 0, 0, .15), inset 1px 1px 4px rgba(255, 255, 255, .08);
}

.result-img {
  border-radius: var(--radius-sm);
  background: #fff;
  flex-shrink: 0;
  justify-content: center;
  align-items: center;
  width: 52px;
  height: 52px;
  padding: 4px;
  display: flex;
  overflow: hidden;
}

.result-img img {
  object-fit: contain;
  width: 100%;
  height: 100%;
  display: block;
}

.result-img-placeholder {
  background: var(--border-subtle);
  border-radius: 4px;
  width: 100%;
  height: 100%;
}

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

.result-name {
  -webkit-line-clamp: 2;
  white-space: normal;
  -webkit-box-orient: vertical;
  margin-bottom: .2rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  overflow: hidden;
}

.result-store {
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 600;
}

.result-carried-badge {
  color: var(--text-muted);
  opacity: .8;
  margin-top: 2px;
  font-size: .7rem;
}

:root {
  --state-stale: #d97706;
  --state-stale-bg: rgba(217, 119, 6, .12);
}

:root[data-theme="light"] {
  --state-stale: #b45309;
  --state-stale-bg: rgba(180, 83, 9, .1);
}

.result-freshness {
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  font-size: .7rem;
  font-weight: 500;
  display: inline-flex;
}

.result-freshness.is-fresh {
  color: var(--text-muted);
}

.result-freshness.is-unknown {
  color: var(--text-muted);
  opacity: .75;
  font-style: italic;
}

.result-freshness.is-stale {
  color: var(--state-stale);
  background: var(--state-stale-bg);
  border-radius: 6px;
  padding: 2px 7px;
}

.result-freshness.is-stale:before {
  content: "⚠";
  font-size: .68rem;
}

.result-price {
  text-align: right;
  font-family: var(--font-ui);
  color: var(--text-primary);
  flex-shrink: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.result-old-price {
  color: var(--text-muted);
  margin-bottom: .1rem;
  font-size: .78rem;
  font-weight: 400;
  text-decoration: line-through;
  display: block;
}

.result-unit-price {
  color: var(--text-muted);
  margin-top: .15rem;
  font-size: .72rem;
  font-weight: 500;
  display: block;
}

.mobile-nav-link {
  color: var(--text-secondary);
  font-size: 1.4rem;
  font-weight: 600;
  text-decoration: none;
  transition: color .2s;
}

.mobile-nav-link:hover {
  color: #fff;
}

#loading, #empty {
  text-align: center;
  padding: 4rem;
}

#search-error {
  text-align: center;
  max-width: 34rem;
  margin: 0 auto;
  padding: 4rem 2rem;
}

#search-error .err-icon {
  margin-bottom: .75rem;
  font-size: 1.9rem;
  line-height: 1;
}

#search-error .err-title {
  color: var(--state-stale);
  margin-bottom: .5rem;
  font-size: 1.15rem;
  font-weight: 600;
}

#search-error .err-body {
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  font-size: .92rem;
  line-height: 1.55;
}

#search-error .err-retry {
  font: inherit;
  color: var(--bg-primary);
  background: var(--accent-primary);
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: .6rem 1.4rem;
  font-size: .9rem;
  font-weight: 600;
  transition: opacity .2s;
}

#search-error .err-retry:hover {
  opacity: .85;
}

.spinner {
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  margin: 0 auto 1.5rem;
  animation: .8s linear infinite spin;
}

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

:root[data-theme="light"] .mobile-nav-link:hover {
  color: var(--accent-primary);
}

#cat-suggest-empty {
  justify-content: center;
  margin-top: 1.25rem;
}

.cat-suggest-label {
  color: var(--text-secondary);
  font-size: .85rem;
}

.cat-suggest-chip {
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated, rgba(255, 255, 255, .04));
  color: var(--text-primary);
  border-radius: 999px;
  align-items: center;
  gap: .4rem;
  padding: .35rem .75rem;
  font-size: .85rem;
  text-decoration: none;
  transition: border-color .2s, color .2s;
  display: inline-flex;
}

.cat-suggest-chip:focus-visible {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.cat-suggest-count {
  color: var(--text-secondary);
  font-size: .75rem;
}

.empty-links {
  margin-top: 1.5rem;
  font-size: .9rem;
}

.empty-links a {
  color: var(--accent-primary);
  text-decoration: none;
}

.cat-suggest {
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin: 0 0 1rem;
  display: flex;
}

.cat-suggest-label {
  color: var(--text-secondary);
  font-size: .8rem;
  font-weight: 600;
}

.cat-suggest-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 100px;
  align-items: center;
  gap: .4rem;
  padding: .4rem .85rem;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color .2s, color .2s;
  display: inline-flex;
}

.cat-suggest-chip:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.cat-suggest-chip:focus-visible {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.cat-suggest-count {
  color: var(--text-secondary);
  font-size: .75rem;
  font-weight: 500;
}

#empty .cat-suggest {
  justify-content: center;
  margin-top: 1rem;
}

.empty-links {
  color: var(--text-secondary);
  margin-top: 1rem;
  font-size: .9rem;
}

.empty-links a {
  color: var(--accent-primary);
  font-weight: 600;
  text-decoration: none;
}

.empty-links a:hover {
  text-decoration: underline;
}

nav .search-bar {
  align-self: center;
  max-width: 640px;
  margin-bottom: 0;
}

:root[data-theme="light"] .search-bar {
  box-shadow: 0 1px 2px rgba(17, 19, 28, .05), 0 8px 22px rgba(17, 19, 28, .06);
}

:root[data-theme="light"] nav {
  --nav-bg: rgba(255, 255, 255, .92);
}
