.search-page { padding: 1.25rem 0 2rem; display: grid; gap: 1.75rem; }
.search-page h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 2.4rem); letter-spacing: -.04em; }
.search-toolbar { display: flex; align-items: stretch; gap: .65rem; position: relative; }
.search-combobox { position: relative; flex: 1; min-width: 0; }
.search-input-wrap { display: flex; align-items: center; gap: .7rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.04); padding: .85rem 1rem; min-height: 3.15rem; box-sizing: border-box; }
.search-genre { position: relative; flex: 0 0 auto; }
.search-genre-button {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  height: 100%;
  min-height: 3.15rem;
  max-width: 9.5rem;
  padding: 0 .85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  color: #fff;
  font: inherit;
  font-size: .9rem;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
  cursor: pointer;
}
.search-genre-button span[data-genre-label] { overflow: hidden; text-overflow: ellipsis; }
.search-genre-button__caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #9a9a9a;
  flex: 0 0 auto;
}
.search-genre-button:hover { background: rgba(255,255,255,.07); }
.search-genre-button--active { color: #00c7be; border-color: rgba(0,199,190,.45); }
.search-genre-button--active .search-genre-button__caret { border-top-color: #00c7be; }
.search-genre-panel {
  position: absolute;
  z-index: 24;
  top: calc(100% + .45rem);
  right: 0;
  width: min(22.5rem, calc(100vw - 2.5rem));
  padding: .45rem;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(10,10,12,.92);
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.search-genre-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.search-genre-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 0;
  padding: .7rem .75rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #ececec;
  font: inherit;
  font-size: .9rem;
  text-align: left;
  cursor: pointer;
}
.search-genre-option--all { margin-bottom: .15rem; }
.search-genre-option:hover { background: rgba(255,255,255,.06); }
.search-genre-option.is-selected { color: #00c7be; }
.search-genre-option.is-selected::after { content: "✓"; font-size: .8rem; color: #00c7be; }
.search-input-wrap__icon { width: 22px; height: 22px; color: #9a9a9a; display: grid; place-items: center; }
.search-input-wrap__icon svg { width: 20px; height: 20px; fill: currentColor; }
.search-input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: #fff; font: inherit; font-size: 1rem; }
.search-input::placeholder { color: #777; }
.search-results { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + .45rem); margin: 0; padding: .35rem; list-style: none; border: 1px solid var(--line); border-radius: 12px; background: rgba(12,12,14,.98); box-shadow: var(--shadow); max-height: min(60vh, 360px); overflow: auto; }
.search-results [role="option"] { display: grid; grid-template-columns: 44px minmax(0,1fr); gap: .75rem; align-items: center; padding: .55rem .6rem; border-radius: 8px; cursor: pointer; }
.search-results [role="option"][aria-selected="true"],
.search-results [role="option"]:hover { background: rgba(255,255,255,.06); }
.search-result__poster { width: 44px; aspect-ratio: 9/16; object-fit: cover; border-radius: 4px; background: #222; }
.search-result__poster--empty { display: block; background: linear-gradient(145deg, #333, #171717); }
.search-result__meta { min-width: 0; display: grid; gap: .15rem; }
.search-result__meta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result__meta small { color: #888; font-size: .75rem; }
.search-status { margin: .65rem 0 0; color: #999; font-size: .85rem; }
.search-status--error { color: #f3a4a4; }

.search-ai-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.15rem;
  min-width: 3.15rem;
  height: 100%;
  min-height: 3.15rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.85);
  font: inherit;
  cursor: pointer;
  flex: 0 0 auto;
}
.search-ai-button__icon { width: 18px; height: 18px; display: grid; place-items: center; color: rgba(255,255,255,.85); }
.search-ai-button__icon svg { width: 18px; height: 18px; fill: currentColor; }
.search-ai-button:hover {
  background: rgba(255,255,255,.10);
  border-color: var(--line);
}
.search-ai-button:disabled,
.search-ai-button[aria-disabled="true"] { opacity: .42; cursor: not-allowed; }
.search-ai-button:disabled:hover,
.search-ai-button[aria-disabled="true"]:hover {
  background: rgba(255,255,255,.06);
  border-color: var(--line);
}

.search-type { position: relative; flex: 0 0 auto; }
.search-type-button {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  height: 100%;
  min-height: 3.15rem;
  max-width: 9.5rem;
  padding: 0 .85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  color: #fff;
  font: inherit;
  font-size: .9rem;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
  cursor: pointer;
}
.search-type-button span[data-content-type-label] { overflow: hidden; text-overflow: ellipsis; }
.search-type-button__caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #9a9a9a;
  flex: 0 0 auto;
}
.search-type-button:hover { background: rgba(255,255,255,.07); }
.search-type-button--active { color: #00c7be; border-color: rgba(0,199,190,.45); }
.search-type-button--active .search-type-button__caret { border-top-color: #00c7be; }
.search-type-panel {
  position: absolute;
  z-index: 24;
  top: calc(100% + .45rem);
  right: 0;
  min-width: 9.5rem;
  padding: .45rem;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(10,10,12,.92);
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.search-type-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 0;
  padding: .7rem .75rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #ececec;
  font: inherit;
  font-size: .9rem;
  text-align: left;
  cursor: pointer;
}
.search-type-option:hover { background: rgba(255,255,255,.06); }
.search-type-option.is-selected { color: #00c7be; }
.search-type-option.is-selected::after { content: "✓"; font-size: .8rem; color: #00c7be; }

.search-catalog { display: grid; gap: .35rem; }
.search-catalog__grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .8rem;
}
.search-catalog__grid .series-card { scroll-snap-align: unset; }
.search-catalog__sentinel { height: 1px; }
.search-catalog__status { margin: .5rem 0 0; color: #999; font-size: .85rem; }

.discovery-chat { display: grid; grid-template-rows: 1fr auto auto; min-height: calc(100dvh - 9.5rem); gap: .75rem; padding-bottom: .5rem; }
.app-shell--no-bottom-nav .discovery-chat { flex: 1; min-height: 0; }
.discovery-chat__messages { overflow: auto; display: grid; gap: .85rem; align-content: start; padding: .25rem 0 1rem; }
.discovery-msg { display: flex; }
.discovery-msg--user { justify-content: flex-end; }
.discovery-msg--assistant { justify-content: flex-start; }
.discovery-msg__bubble { max-width: min(92%, 34rem); padding: .85rem 1rem; border-radius: 16px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.discovery-msg--user .discovery-msg__bubble { background: #1f6b4a; color: #fff; border-bottom-right-radius: 6px; }
.discovery-msg--assistant .discovery-msg__bubble { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); border-bottom-left-radius: 6px; }
.discovery-msg__bubble--typing { display: inline-flex; gap: .35rem; align-items: center; min-width: 3.2rem; }
.discovery-msg__bubble--typing span { width: .45rem; height: .45rem; border-radius: 50%; background: #bbb; animation: discovery-pulse 1s infinite ease-in-out; }
.discovery-msg__bubble--typing span:nth-child(2) { animation-delay: .15s; }
.discovery-msg__bubble--typing span:nth-child(3) { animation-delay: .3s; }
@keyframes discovery-pulse { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

.discovery-rec { display: grid; grid-template-columns: 72px minmax(0,1fr); gap: .9rem; padding: .9rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.03); max-width: min(92%, 34rem); }
.discovery-rec__poster { width: 72px; aspect-ratio: 9/16; object-fit: cover; border-radius: 6px; background: #222; }
.discovery-rec__poster--empty { background: linear-gradient(145deg, #333, #171717); }
.discovery-rec__body { display: grid; gap: .45rem; align-content: start; }
.discovery-rec__body h3 { margin: 0; font-size: 1.05rem; }
.discovery-rec__body p { margin: 0; color: #bdbdbd; font-size: .9rem; }
.discovery-rec__meta { color: #888 !important; font-size: .78rem !important; }

.discovery-chat__composer { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .65rem; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: .65rem; background: rgba(255,255,255,.03); }
.discovery-input { width: 100%; border: 0; outline: 0; background: transparent; color: #fff; font: inherit; line-height: 1; height: 44px; min-height: 44px; max-height: 44px; padding: 0 .45rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.discovery-error { margin: 0; color: #f3a4a4; font-size: .85rem; }
.text-button { background: transparent; border: 0; color: #bbb; font: inherit; font-weight: 700; font-size: .8rem; cursor: pointer; padding: .35rem .5rem; }
.text-button:hover { color: #fff; }
.topbar .text-button { margin-left: auto; }

@media (max-width: 480px) {
  .search-toolbar { gap: .5rem; }
  .search-input-wrap { padding: .75rem .85rem; min-height: 3rem; }
  .search-ai-button { min-height: 3rem; padding: 0 .7rem; font-size: .82rem; }
  .search-genre-button { min-height: 3rem; max-width: 7.25rem; padding: 0 .7rem; font-size: .82rem; }
  .search-genre-panel { width: min(20.5rem, calc(100vw - 1.25rem)); }
}

@media (max-width: 1100px) {
  .search-catalog__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .search-catalog__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .search-toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
    gap: .5rem;
  }
  .search-combobox {
    grid-column: 1 / -1;
  }
  .search-ai-button {
    width: 3rem;
    min-width: 3rem;
    height: 3rem;
    min-height: 3rem;
    padding: 0;
  }
  .search-type,
  .search-genre {
    min-width: 0;
  }
  .search-type-button,
  .search-genre-button {
    width: 100%;
    max-width: none;
    min-height: 3rem;
    box-sizing: border-box;
  }
  .search-type-button span[data-content-type-label],
  .search-genre-button span[data-genre-label] {
    min-width: 0;
    flex: 1;
  }
  .search-catalog__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
}

@media (min-width: 760px) {
  .search-page { padding-top: 1.75rem; }
  .discovery-chat { min-height: calc(100dvh - 8rem); }
  .app-shell--no-bottom-nav .discovery-chat { min-height: 0; }
}
