:root {
  --bg: #F6F8F7;
  --surface: #FFFFFF;
  --text: #14201D;
  --muted: #66756F;
  --accent: #00614A;
  --on-accent: #FFFFFF;
  --border: #E1E1E1;
  --shadow: rgba(20, 32, 29, 0.07);
  --app-header-height: calc(env(safe-area-inset-top) + 65px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1512;
    --surface: #101E1A;
    --text: #F3F6F4;
    --muted: #8FA39D;
    --accent: #1FBA8F;
    --on-accent: #04231C;
    --border: #1E2E29;
    --shadow: rgba(0, 0, 0, 0.3);
  }
}

:root[data-theme="dark"] {
  --bg: #0A1512;
  --surface: #101E1A;
  --text: #F3F6F4;
  --muted: #8FA39D;
  --accent: #1FBA8F;
  --on-accent: #04231C;
  --border: #1E2E29;
  --shadow: rgba(0, 0, 0, 0.3);
}

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

html {
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

img,
svg {
  -webkit-user-drag: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- ambient signal ---------- */
.ambient-signal {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 100% 40% at 50% 0%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 70%);
}

/* ---------- fixed header ---------- */
.explore-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-icon-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
}

.header-icon-btn:active {
  transform: scale(0.9);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.header-icon-btn svg {
  width: 19px;
  height: 19px;
}

.header-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header-spacer {
  flex: none;
  width: 40px;
}

/* ---------- main content ---------- */
.explore-content {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--app-header-height) + 18px) max(20px, env(safe-area-inset-right)) 40px max(20px, env(safe-area-inset-left));
}

.explore-sub {
  margin-bottom: 18px;
  font-size: 13.5px;
  color: var(--muted);
}

/* ---------- large search field ---------- */
.search-bar-lg {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 54px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.search-bar-lg:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 13%, transparent);
}

.search-icon-lg {
  flex: none;
  width: 21px;
  height: 21px;
  color: var(--muted);
  transition: color 180ms ease;
}

.search-bar-lg:focus-within .search-icon-lg {
  color: var(--accent);
}

.search-input-lg {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
}

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

.search-clear-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 0;
  background: color-mix(in srgb, var(--muted) 16%, transparent);
  color: var(--muted);
  cursor: pointer;
  transition: transform 120ms ease, opacity 150ms ease;
}

.search-clear-btn:active {
  transform: scale(0.88);
}

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

/* ---------- suggestions / popular searches ---------- */
.suggestions-panel {
  margin-top: 24px;
}

.section-title {
  padding: 0 2px;
  margin-bottom: 12px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.popular-searches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  animation: panel-enter 260ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.popular-chip {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background-color 150ms ease, border-color 150ms ease;
}

.popular-chip:active {
  transform: scale(0.95);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

@keyframes panel-enter {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

.category-section-title {
  margin-top: 22px;
}

.category-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  animation: panel-enter 260ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.category-card {
  position: relative;
  aspect-ratio: 1 / 1.05;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 24%, var(--surface)), color-mix(in srgb, var(--accent) 8%, var(--surface)));
  cursor: pointer;
  transition: transform 120ms ease;
}

.category-card:active {
  transform: scale(0.96);
}

.category-card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Fixed dark-on-photo treatment regardless of theme — same reasoning as
   the Home hero: the photo has no light/dark variant, so the label needs
   a guaranteed-readable overlay rather than a theme-token color. */
.category-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 16, 13, 0.05) 45%, rgba(6, 12, 10, 0.75) 100%);
}

.category-card-label {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-align: left;
  letter-spacing: -0.01em;
}

.suggestion-list {
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.suggestion-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  background: none;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 150ms ease;
  animation: suggestion-enter 200ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.suggestion-row + .suggestion-row {
  border-top: 1px solid var(--border);
}

.suggestion-row:active {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

@keyframes suggestion-enter {
  from { opacity: 0; transform: translate3d(0, 6px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

.suggestion-icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg);
  font-size: 19px;
  line-height: 1;
}

.suggestion-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.suggestion-name {
  font-size: 14.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-category {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-arrow {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--muted);
}

/* ---------- no-match state ---------- */
.no-matches {
  padding: 22px 4px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .popular-searches,
  .category-cards,
  .suggestion-row {
    animation: none;
  }
  .header-icon-btn,
  .search-bar-lg,
  .search-icon-lg,
  .popular-chip,
  .category-card,
  .suggestion-row,
  .search-clear-btn {
    transition: none;
  }
}
