.search-form {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}
@media (min-width: 600px) {
  .search-form { max-width: 260px; margin-left: auto; }
}

.search-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  padding: 10px 14px;
  outline: none;
}

#searchDialog .more-like-header { gap: 8px; padding-top: 0; }
body:has(#searchDialog[open]) #posterViewClose { display: none; }

.search-back {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: var(--text);
  padding: 4px 2px;
  cursor: pointer;
  opacity: 0.6;
  min-height: unset;
}
.search-action {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  color: var(--text);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.6;
  font-size: 0.9rem;
  min-height: unset;
  line-height: 1;
  padding: 0;
}
.search-action:hover { opacity: 1; background: rgba(255, 255, 255, 0.14); }

.search-form {
  position: relative;
}
.search-input { padding-right: 36px; }
.search-inline-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  padding: 4px;
  cursor: pointer;
  min-height: unset;
  line-height: 1;
  opacity: 0.5;
}
.search-inline-btn:hover { opacity: 1; }
.search-context {
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-context[hidden] { display: none; }
.search-context-back {
  background: none;
  border: none;
  color: var(--text);
  padding: 0;
  cursor: pointer;
  min-height: unset;
  opacity: 0.7;
  line-height: 1;
}
.search-context-back:hover { opacity: 1; }
.search-context-back svg { display: block; }
.search-context-title {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}
.search-context-title em {
  font-style: normal;
  color: var(--text);
}

.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: rgba(255, 255, 255, 0.28); }

/* Hide Chrome's native clear/cancel affordances on type=search — the input
   sits in a custom header and the dialog close button already clears it. */
.search-input::-webkit-search-cancel-button { display: none; }

#searchResults {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(45%, 220px), 1fr));
  grid-auto-flow: row;
  grid-auto-rows: auto;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  scroll-snap-type: none;
  padding-right: 0;
  mask-image: none;
  /* Vertical grid: only allow vertical panning so a sideways swipe doesn't
     trigger a horizontal stretch-overscroll that springs back. */
  touch-action: pan-y;
  overscroll-behavior: contain;
}
#searchResults::-webkit-scrollbar { display: none; }

#searchResults .row-item {
  width: 100%;
  height: auto;
}

/* Override the horizontal-row cards' pan-x (posterCard.css) — this grid
   scrolls vertically. */
#searchResults .item-card { touch-action: pan-y; }

#searchResults .row-item .item-card {
  width: 100%;
  height: auto;
  aspect-ratio: 2/3;
}

#searchMoods { flex: 1; min-height: 0; overflow-y: auto; }
#searchResults[hidden] { display: none; }

.search-fallback {
  display: block;
  text-align: center;
  padding: 12px;
  color: rgba(255, 255, 255, 0.25);
  font-size: 0.75rem;
  text-decoration: none;
}

.search-fallback:hover { color: var(--muted); }

@media (max-height: 500px) and (orientation: landscape) {
  #searchResults { --rows: 1; }
}
