.pb-filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  white-space: nowrap;
  min-height: 40px;
  padding: 8px 13px;
  margin: 4px;
  border: 1px solid #539B98;
  border-radius: 10px;
  background: #273131;
  color: #DCE5E3;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.pb-filter-button:hover,.pb-filter-button.is-active {
  background: #466362;
  border-color: #68DCD7;
}

.pb-filter-dialog {
  box-sizing: border-box;
  width: min(440px,calc(100% - 32px));
  max-height: 85dvh;
  overflow: auto;
  padding: 26px;
  border: 1px solid #3F4A4A;
  border-radius: 22px;
  background: #161A1A;
  color: #DCE5E3;
  box-shadow: 0 24px 100px #0009;
  font-family: inherit;
  color-scheme: dark;
}

.pb-filter-dialog::backdrop {
  background: #090D0DAA;
  backdrop-filter: blur(5px);
}

.pb-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.pb-filter-head h2 {
  font-size: 24px;
  margin: 0;
  letter-spacing: -.6px;
}

.pb-close {
  width: 40px;
  height: 40px;
  border: 1px solid #3F4A4A;
  border-radius: 50%;
  background: #242A2A;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.pb-filter-intro {
  color: #B1BDBD;
  font-size: 14px;
  margin: 9px 0 24px;
}

.pb-filter-field {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 17px 0;
}

.pb-filter-field select {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 47px;
  margin-top: 9px;
  padding: 10px 12px;
  background: #202626;
  border: 1px solid #3F4A4A;
  border-radius: 10px;
  color: #DCE5E3;
  font: inherit;
}

.pb-filter-note {
  font-size: 12px;
  color: #AFBCBB;
  line-height: 1.6;
}

.pb-filter-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.pb-filter-actions button {
  min-height: 46px;
  border-radius: 11px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.pb-reset {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid #3F4A4A;
  color: #98C7C5;
}

.pb-apply {
  flex: 1;
  background: #68DCD7;
  color: #141F1F;
  border: 0;
}

.pb-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  flex-basis: 100%;
}

.pb-filter-chips[hidden] {
  display: none;
}

.pb-chip,.pb-clear {
  padding: 7px 10px;
  border-radius: 20px;
  border: 1px solid #4E6261;
  background: #232E2D;
  color: #DCE5E3;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.pb-clear {
  background: transparent;
  border-color: transparent;
  color: #BAC5C4;
}

.pb-filter-button:focus-visible,.pb-filter-dialog :focus-visible,.pb-filter-chips button:focus-visible {
  outline: 2px solid #78DFDB!important;
  outline-offset: 3px;
}

@media(max-width:600px) {
  .pb-filter-dialog {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
    max-height: 90dvh;
  }

  .pb-filter-button {
    padding: 8px 10px;
    font-size: 12px;
  }

  .pb-filter-chips {
    gap: 6px;
  }

}

.search-results-head:has(.pb-filter-chips) {
  flex-wrap: wrap;
}

/* Results controls stay out of the header on every screen size. */
.pb-result-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.pb-result-actions .pb-filter-button {
  margin: 0;
  min-height: 42px;
}
.content-section .section-heading {
  flex-wrap: wrap;
}
@media (max-width: 720px) {
  .search-results-head {
    align-items: flex-start;
    gap: 16px;
  }
  .pb-result-actions {
    width: 100%;
  }
  .header .search-wrap {
    min-width: 0 !important;
    width: 100%;
  }
  .header .search-box {
    min-width: 0 !important;
    width: 100%;
    box-sizing: border-box;
  }
  .header .search-input {
    min-width: 0 !important;
    width: 0;
    flex: 1 1 0%;
    font-size: 16px;
  }
  .header .search-shortcut {
    display: none;
  }
  .header .search-btn {
    flex: 0 0 auto;
    min-height: 40px;
  }
}

/* Anchored dropdown: same compact panel on desktop and mobile. */
.pb-filter-dialog.pb-filter-popover {
  position: absolute;
  z-index: 10050;
  margin: 0;
  padding: 20px;
  max-width: calc(100vw - 24px);
  max-height: min(540px, 75dvh);
  border: 1px solid #4C5F5E;
  border-radius: 16px;
  background: #161C1B;
  box-shadow: 0 18px 50px #0008;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: pb-filter-enter 140ms ease-out;
}

.pb-filter-popover[hidden] {
  display: none !important;
}

.pb-filter-popover .pb-filter-head h2 {
  font-size: 19px;
}

.pb-filter-popover .pb-filter-intro {
  margin: 6px 0 16px;
  font-size: 13px;
}

.pb-filter-popover .pb-filter-field {
  margin: 13px 0;
}

.pb-filter-popover .pb-filter-actions {
  margin-top: 16px;
}

@keyframes pb-filter-enter {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pb-filter-dialog.pb-filter-popover {
    animation: none;
  }
}

/* Category filters share the search toolbar with Surprise me. */
.toolbar .pb-category-toolbar-actions {
  width: auto;
  flex: 0 0 auto;
}

@media (max-width: 600px) {
  .toolbar:has(.pb-category-toolbar-actions) {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .toolbar:has(.pb-category-toolbar-actions) > .search-box {
    width: 100%;
    flex: 1 0 100%;
    box-sizing: border-box;
  }

  .toolbar .pb-category-toolbar-actions {
    flex: 1 1 auto;
  }
}

/* Designed select controls and their native option menu. */
.pb-filter-field {
  position: relative;
}

.pb-filter-field select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 48px;
  padding: 11px 42px 11px 14px;
  border: 1px solid #465454;
  border-radius: 12px;
  background-color: #1F2726;
  background-image:
    linear-gradient(45deg, transparent 50%, #7ECAC7 50%),
    linear-gradient(135deg, #7ECAC7 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 20px,
    calc(100% - 13px) 20px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  color: #DCE5E3;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.pb-filter-field select:hover {
  border-color: #529895;
  background-color: #252E2D;
}

.pb-filter-field select:focus {
  border-color: #67CBC6;
  box-shadow: 0 0 0 3px rgba(103,203,198,0.16);
  outline: none;
}

.pb-filter-field select option {
  padding: 12px;
  background: #1F2726;
  color: #DCE5E3;
}

/* Category settings icon stays beside Surprise me at every width. */
.pb-settings-button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border-radius: 12px;
  font-size: 20px;
  line-height: 1;
}

.toolbar .pb-category-toolbar-actions {
  display: flex;
  width: 44px;
  min-width: 44px;
  flex: 0 0 44px;
}

.toolbar #randomPromptBtn {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  flex: 0 0 auto;
}

@media (max-width: 600px) {
  .toolbar:has(.pb-category-toolbar-actions) {
    display: flex;
    flex-flow: row nowrap;
    align-items: stretch;
    gap: 8px;
  }

  .toolbar:has(.pb-category-toolbar-actions) > .search-box {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
  }

  .toolbar .pb-category-toolbar-actions {
    width: 42px;
    min-width: 42px;
    flex: 0 0 42px;
  }

  .pb-settings-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
  }

  .toolbar #randomPromptBtn {
    min-width: 76px;
    min-height: 42px;
    padding: 8px 10px;
  }
}

/* Fully designed PromptBx option menus. */
.pb-filter-label {
  display: block;
  margin-bottom: 9px;
  color: #DCE5E3;
  font-size: 13px;
  font-weight: 700;
}

.pb-native-select {
  display: none !important;
}

.pb-custom-select {
  position: relative;
}

.pb-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid #465454;
  border-radius: 12px;
  background: linear-gradient(180deg, #242B2B 0%, #1F2525 100%);
  color: #DCE5E3;
  font-family: inherit;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.pb-select-trigger:hover {
  border-color: #539A97;
  background: linear-gradient(180deg, #293231 0%, #232B2B 100%);
}

.pb-custom-select.is-open .pb-select-trigger,
.pb-select-trigger:focus-visible {
  border-color: #67D2CE;
  box-shadow: 0 0 0 3px rgba(103,210,206,0.16);
  outline: none;
}

.pb-select-arrow {
  flex: 0 0 auto;
  color: #83D1CE;
  font-size: 19px;
  line-height: 1;
  transition: transform 150ms ease;
}

.pb-custom-select.is-open .pb-select-arrow {
  transform: rotate(180deg);
}

.pb-select-options {
  position: absolute;
  z-index: 10070;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  max-height: 230px;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #4B5A59;
  border-radius: 13px;
  background: #181C1C;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.52);
  scrollbar-width: thin;
  scrollbar-color: #4C8C8A #1E2525;
  animation: pb-options-enter 120ms ease-out;
}

.pb-select-options[hidden] {
  display: none !important;
}

.pb-select-option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #DCE5E3;
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
}

.pb-select-option:hover,
.pb-select-option:focus-visible {
  background: #2A3232;
  color: #ffffff;
  outline: none;
}

.pb-select-option.is-selected {
  background: linear-gradient(90deg, #4D8E8B 0%, #427B78 100%);
  color: #ffffff;
  font-weight: 750;
}

.pb-select-option.is-selected::after {
  content: '✓';
  margin-left: auto;
  color: #DCE5E3;
  font-weight: 800;
}

@keyframes pb-options-enter {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pb-select-options,
  .pb-select-arrow {
    animation: none;
    transition: none;
  }
}