/* ---------- Search overlay ---------- */
.sx { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; justify-content: center; align-items: flex-start; padding: min(8vh, 72px) var(--gutter) var(--gutter); }
.sx__scrim { position: absolute; inset: 0; background: var(--overlay); backdrop-filter: blur(4px); animation: sxFade var(--dur-base) var(--ease); }
.sx__panel {
  position: relative; width: min(680px, 100%); max-height: calc(100vh - min(8vh, 72px) - 24px); display: flex; flex-direction: column;
  background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: 0 32px 64px -16px rgba(0, 0, 0, .7); overflow: hidden;
  animation: sxIn var(--dur-slow) var(--ease);
}
@keyframes sxFade { from { opacity: 0; } }
@keyframes sxIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
.sx__bar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-4); border-bottom: 1px solid var(--border); }
.sx__bar > .icon { color: var(--text-3); width: 22px; height: 22px; }
.sx__bar input { flex: 1; min-width: 0; height: 52px; border: 0; outline: none; background: transparent; color: var(--text-1); font-size: var(--fs-18); }
.sx__bar input::placeholder { color: var(--text-3); }
.sx__bar input::-webkit-search-cancel-button { display: none; }
.sx__close { display: inline-flex; align-items: center; gap: var(--sp-2); height: 36px; padding: 0 var(--sp-2); border: 0; border-radius: var(--r-md); background: none; color: var(--text-3); }
.sx__close:hover { background: var(--surface-2); color: var(--text-1); }
.sx__close .icon { display: none; }
kbd { font-family: var(--font); font-size: 11px; line-height: 20px; padding: 0 6px; border-radius: 5px; border: 1px solid var(--border-strong); color: var(--text-2); background: var(--surface-2); }

.sx__body { overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-2); scrollbar-width: none; }
.sx__body::-webkit-scrollbar { display: none; }
.sx__group + .sx__group { margin-top: var(--sp-1); padding-top: var(--sp-1); border-top: 1px solid var(--border); }
.sx__head { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-2) var(--sp-3); font-size: var(--fs-12); font-weight: 700; color: var(--text-3); }
.sx__head button { background: none; border: 0; color: var(--accent-text); font-size: var(--fs-12); font-weight: 700; }
.sx__chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: 0 var(--sp-3) var(--sp-2); }
.sx__chips .chip { height: 32px; }

.sx__item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md); transition: background-color var(--dur-fast) var(--ease); }
.sx__item:hover, .sx__item.is-active { background: var(--surface-2); }
.sx__item.is-active { box-shadow: inset 2px 0 0 var(--accent); }
.sx__item img { width: 44px; aspect-ratio: 2 / 3; border-radius: var(--r-sm); object-fit: cover; flex-shrink: 0; background: var(--surface-3); }
.sx__text { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.5; }
.sx__text b { font-size: var(--fs-14); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx__text small { font-size: var(--fs-12); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx__text small.ltr { text-align: right; }
.sx mark { background: var(--accent-soft); color: var(--accent-text); border-radius: 3px; padding: 0 1px; }
.sx__score { flex-shrink: 0; min-width: 40px; height: 26px; padding: 0 8px; border-radius: var(--r-sm); background: var(--surface-3); display: grid; place-items: center; font-size: var(--fs-12); font-weight: 800; }
.sx__avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--accent-soft); color: var(--accent-text); font-weight: 800; }
.sx__all { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-2); padding: var(--sp-3); border-radius: var(--r-md); font-size: var(--fs-14); font-weight: 700; color: var(--accent-text); background: var(--accent-soft); }
.sx__all:hover, .sx__all.is-active { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.sx__empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-7) var(--sp-4); text-align: center; color: var(--text-2); font-size: var(--fs-14); }
.sx__empty .icon { width: 40px; height: 40px; color: var(--text-3); margin-bottom: var(--sp-2); }
.sx__empty b { color: var(--text-1); font-size: var(--fs-16); }
.sx__empty .btn { margin-top: var(--sp-3); }
.sx__foot { display: flex; gap: var(--sp-5); padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border); font-size: var(--fs-12); color: var(--text-3); }
.sx__foot span { display: inline-flex; align-items: center; gap: 4px; }

/* header field acts as a trigger */
.header-search .input[readonly] { cursor: pointer; }

@media (max-width: 960px) {
  .sx { padding: 0; }
  .sx__panel { width: 100%; max-height: none; height: 100%; border-radius: 0; border: 0; }
  .sx__close kbd { display: none; }
  .sx__close .icon { display: block; }
  .sx__foot { display: none; }
  .sx__bar input { font-size: var(--fs-16); }
}

/* ---------- Search v2: trending posters, genre tiles, best match ---------- */
.sx__panel { width: min(760px, 100%); }
.sx__recent { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--sp-3); border-radius: var(--r-full); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-13); }
.sx__recent:hover { color: var(--text-1); border-color: var(--border-strong); }
.sx__trend { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--sp-3); padding: 0 var(--sp-3) var(--sp-1); }
.sx__poster { flex-direction: column; align-items: stretch; gap: 6px; padding: 0; background: none !important; }
.sx__poster-img { position: relative; display: block; aspect-ratio: 3 / 4; border-radius: var(--r-md); overflow: hidden; background: var(--surface-3); }
.sx__poster .sx__poster-img img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--dur-slow) var(--ease); }
.sx__poster:hover .sx__poster-img img, .sx__poster.is-active .sx__poster-img img { transform: scale(1.05); }
.sx__poster.is-active { box-shadow: none; }
.sx__poster.is-active .sx__poster-img { outline: 2px solid var(--accent); outline-offset: 2px; }
.sx__poster-img i { position: absolute; bottom: 4px; inset-inline-start: 6px; font-style: normal; font-size: 30px; font-weight: 800; line-height: 1; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .8); }
.sx__poster b { font-size: var(--fs-13); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx__poster small { font-size: 11px; color: var(--text-3); margin-top: -4px; }
.sx__genres { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); padding: 0 var(--sp-3) var(--sp-2); }
.sx__genre {
  position: relative; isolation: isolate; overflow: hidden; height: 52px; border-radius: var(--r-md);
  display: flex; align-items: center; padding: 0 var(--sp-3); color: #fff; font-weight: 800; font-size: var(--fs-14);
  background: linear-gradient(135deg, hsl(var(--h) 55% 30%), hsl(calc(var(--h) + 30) 50% 14%));
  transition: transform var(--dur-base) var(--ease);
}
.sx__genre:hover { transform: translateY(-2px); }
.sx__genres .sx__genre img { position: absolute; z-index: -1; top: 6px; width: 32px; height: 48px; object-fit: cover; border-radius: 6px; box-shadow: 0 6px 14px rgba(0, 0, 0, .5); }
.sx__genre img:nth-of-type(1) { inset-inline-end: 10px; transform: rotate(10deg); }
.sx__genre img:nth-of-type(2) { inset-inline-end: 34px; transform: rotate(-6deg) translateY(6px); opacity: .85; }

.sx__best {
  position: relative; isolation: isolate; overflow: hidden; align-items: stretch; gap: var(--sp-4);
  margin-bottom: var(--sp-2); padding: var(--sp-4) !important; border-radius: var(--r-lg);
  border: 1px solid var(--border-strong); background: var(--surface-2);
}
.sx__best .sx__best-bg { position: absolute; inset: -40px; z-index: -2; width: calc(100% + 80px); height: calc(100% + 80px); object-fit: cover; filter: blur(30px) saturate(1.3); opacity: .45; }
.sx__best::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to left, rgba(11, 11, 15, .2), rgba(11, 11, 15, .85)); }
.sx__best .sx__best-poster { width: 96px; aspect-ratio: 2 / 3; border-radius: var(--r-md); object-fit: cover; flex-shrink: 0; box-shadow: 0 14px 30px rgba(0, 0, 0, .55); }
.sx__best-info { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.sx__best-tag { font-size: 11px; font-weight: 800; color: var(--accent-text); }
.sx__best-info > b { font-size: var(--fs-22); font-weight: 800; line-height: 1.3; }
.sx__best-en { font-size: var(--fs-13); color: var(--text-2); text-align: right; }
.sx__best-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--fs-13); color: var(--text-2); }
.sx__best-meta .badge { height: 20px; font-size: 11px; }
.sx__best-cta { margin-top: var(--sp-2); }
.sx__best.is-active { box-shadow: inset 0 0 0 2px var(--accent); }
.sx__people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
.sx__item img.sx__avatar { width: 44px; height: 44px; aspect-ratio: auto; border-radius: 50%; object-fit: cover; object-position: center 20%; }

@media (max-width: 960px) {
  .sx__trend { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 30%; overflow-x: auto; scrollbar-width: none; }
  .sx__genres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sx__people { grid-template-columns: 1fr; }
  .sx__best .sx__best-poster { width: 80px; }
  .sx__best-info > b { font-size: var(--fs-18); }
}
