/* 商品目录的排序、搜索与范围切换共用一个轻量胶囊。 */
.catalog-tools {
  width: min(760px, 100%);
  max-width: 100%;
  min-width: 0;
  display: block;
  flex: 0 1 auto;
}

.catalog-results-header {
  position: relative;
  z-index: 20;
  flex-wrap: wrap;
  overflow: visible;
}

/* 旧移动端规则按两个控件分列；新表单自行负责内部布局。 */
.catalog-results-header .catalog-tools {
  display: block !important;
}

.catalog-capsule {
  --catalog-toolbar-ink: #19253a;
  --catalog-toolbar-muted: #68758a;
  --catalog-toolbar-line: #e5eaf3;
  --catalog-toolbar-track: #f0f3f8;
  --catalog-toolbar-focus: #566fbc;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 12px 14px 12px 18px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 148px minmax(160px, 1fr) 184px;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--catalog-toolbar-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 26px rgba(36, 57, 99, 0.065), 0 2px 5px rgba(36, 57, 99, 0.025);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--catalog-toolbar-ink);
  font-family: -apple-system, BlinkMacSystemFont, 'HarmonyOS Sans SC', 'Microsoft YaHei', sans-serif;
}

.catalog-capsule .catalog-sort-label {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 44px;
  margin: 0;
  padding-right: 14px;
  border-right: 1px solid var(--catalog-toolbar-line);
  display: flex;
  align-items: center;
}

.catalog-capsule .catalog-sort-toggle {
  width: 100%;
  min-width: 0;
  height: 44px;
  margin: 0;
  padding: 0 22px 0 6px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  background-image: none;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  color: var(--catalog-toolbar-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.catalog-capsule .catalog-sort-caption {
  white-space: nowrap;
}

.catalog-capsule .catalog-sort-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 12px);
  left: 0;
  width: 208px;
  padding: 6px;
  border: 1px solid var(--catalog-toolbar-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 32px rgba(36, 57, 99, 0.13), 0 2px 6px rgba(36, 57, 99, 0.04);
  animation: catalog-sort-appear 160ms ease-out;
}

.catalog-capsule .catalog-sort-popover[hidden] {
  display: none;
}

.catalog-capsule .catalog-sort-popover [role="option"] {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: transparent;
  color: var(--catalog-toolbar-ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.catalog-capsule .catalog-sort-popover [role="option"]:hover,
.catalog-capsule .catalog-sort-popover [role="option"]:focus-visible {
  background: #f6f8fc;
}

.catalog-capsule .catalog-sort-popover [aria-selected="true"] {
  background: var(--catalog-toolbar-track);
  font-weight: 600;
}

.catalog-capsule .catalog-sort-popover [role="option"] i {
  visibility: hidden;
  font-size: 12px;
}

.catalog-capsule .catalog-sort-popover [aria-selected="true"] i {
  visibility: visible;
}

@keyframes catalog-sort-appear {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.catalog-capsule .catalog-sort-chevron {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--catalog-toolbar-muted);
  font-size: 11px;
  pointer-events: none;
}

.catalog-capsule .catalog-search {
  width: 100%;
  min-width: 0;
  height: 44px;
  margin: 0;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #e9eef6;
  border-radius: 999px;
  background: #f8fafd;
  box-shadow: none;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.catalog-capsule .catalog-search:focus-within {
  border-color: #cbd5e7;
  background: #ffffff;
  box-shadow: none;
}

.catalog-capsule .catalog-search .item-search-button {
  width: 32px;
  height: 40px;
  flex: 0 0 32px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  color: var(--catalog-toolbar-muted);
  font-size: 16px;
  cursor: pointer;
  transition: color 160ms ease, transform 120ms ease;
}

.catalog-capsule .catalog-search .item-search-button:hover {
  color: var(--catalog-toolbar-ink);
}

.catalog-capsule .catalog-search .item-search-button:active {
  transform: scale(0.94);
}

.catalog-capsule .catalog-search-input {
  width: 100%;
  min-width: 0;
  height: 40px;
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: var(--catalog-toolbar-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
}

.catalog-capsule .catalog-search-input::placeholder {
  color: var(--catalog-toolbar-muted);
  opacity: 1;
}

.catalog-capsule .catalog-search-clear {
  width: 36px;
  height: 40px;
  flex: 0 0 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--catalog-toolbar-muted);
  cursor: pointer;
}

.catalog-capsule .catalog-search-clear[hidden] {
  display: none;
}

.catalog-capsule .catalog-search-clear:hover {
  color: var(--catalog-toolbar-ink);
  background: #edf1f7;
}

.catalog-capsule .catalog-search-scope {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-width: 0;
  height: 44px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 0;
  border-radius: 999px;
  background: var(--catalog-toolbar-track);
}

.catalog-capsule .catalog-search-scope::before {
  content: '';
  position: absolute;
  z-index: 0;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc((100% - 4px) / 2);
  box-sizing: border-box;
  border: 1px solid rgba(227, 233, 244, 0.65);
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(43, 62, 101, 0.085);
  transform: translate3d(0, 0, 0);
  transition: transform 440ms cubic-bezier(0.35, 0, 0.2, 1);
}

.catalog-capsule .catalog-search-scope.is-all::before {
  transform: translate3d(100%, 0, 0);
}

.catalog-capsule .catalog-search-scope-option {
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  height: 44px;
  margin: 0;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  color: var(--catalog-toolbar-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color 180ms ease;
}

.catalog-capsule .catalog-search-scope-option.is-active {
  color: var(--catalog-toolbar-ink);
  font-weight: 600;
}

.catalog-capsule .catalog-search-scope-option:hover {
  color: var(--catalog-toolbar-ink);
}

.catalog-capsule :is(button, input, select):focus-visible {
  outline: 2px solid var(--catalog-toolbar-focus);
  outline-offset: -3px;
}

.catalog-pagination {
  min-height: 48px;
  margin: 22px 0 4px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--pilot-muted, #68758a);
}

.catalog-pagination[hidden] {
  display: none;
}

.catalog-pagination :is(button, a),
.catalog-empty-action {
  min-width: 44px;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid #e2e8f2;
  border-radius: 12px;
  background: #fff;
  color: #23314a;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.catalog-pagination :is(button, a):hover,
.catalog-empty-action:hover {
  border-color: #c9d4e7;
  background: #f6f8fc;
}

.catalog-pagination :is(button, a):focus-visible,
.catalog-empty-action:focus-visible {
  outline: 2px solid #566fbc;
  outline-offset: 2px;
}

.catalog-pagination :is(button, a):disabled,
.catalog-pagination a[aria-disabled="true"] {
  cursor: default;
  opacity: .42;
}

.catalog-page-numbers {
  display: flex;
  align-items: center;
  gap: 6px;
}

.catalog-page-numbers :is(button, a).is-current {
  border-color: #5068b1;
  background: #5068b1;
  color: #fff;
}

.catalog-page-gap {
  min-width: 20px;
  text-align: center;
}

.catalog-page-status {
  display: none;
  white-space: nowrap;
  font-size: 13px;
}

.catalog-empty-action {
  margin-top: 12px;
}

@media (max-width: 1100px) {
  .catalog-results-header {
    flex-wrap: wrap;
    gap: 18px;
  }

  .catalog-results-header .catalog-tools {
    width: 100%;
    flex-basis: 100%;
  }
}

@media (max-width: 600px) {
  .catalog-capsule {
    grid-template-columns: minmax(120px, 0.85fr) minmax(156px, 1.15fr);
    gap: 10px;
    padding: 12px;
    border-radius: 24px;
  }

  .catalog-capsule .catalog-sort-label {
    grid-column: 1;
    grid-row: 1;
    padding-right: 4px;
    border-right: 0;
  }

  .catalog-capsule .catalog-sort-chevron {
    right: 8px;
  }

  .catalog-capsule .catalog-sort-toggle {
    padding-left: 4px;
  }

  .catalog-capsule .catalog-search-scope {
    grid-column: 2;
    grid-row: 1;
  }

  .catalog-capsule .catalog-search {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .catalog-capsule .catalog-search-input {
    font-size: 16px;
  }

  .catalog-capsule .catalog-search-scope-option {
    padding-inline: 5px;
  }

  .catalog-pagination {
    justify-content: space-between;
    gap: 6px;
  }

  .catalog-page-numbers {
    display: none;
  }

  .catalog-page-status {
    display: inline;
  }

  .catalog-pagination > :is(button, a) {
    padding-inline: 12px;
  }
}

@media (max-width: 360px) {
  .catalog-capsule {
    grid-template-columns: minmax(0, 1fr);
  }

  .catalog-capsule .catalog-search-scope {
    grid-column: 1;
    grid-row: 2;
  }

  .catalog-capsule .catalog-search {
    grid-row: 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .catalog-capsule .catalog-sort-popover {
    animation: none;
  }
  .catalog-capsule .catalog-search,
  .catalog-capsule .catalog-search-scope-option,
  .catalog-capsule .item-search-button {
    transition-duration: 0.01ms !important;
  }

  /* 保留用户明确要求的选择轨迹，缩短其余运动反馈。 */
  .catalog-capsule .catalog-search-scope::before {
    transition-duration: 200ms !important;
  }
}

.catalog-pagination a { display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
