/* Feed controls mobile refactor */
#main-feed-shell.main-feed-page-shell .sp-discovery-hero {
  padding: 10px 0 8px !important;
}

#main-feed-shell.main-feed-page-shell .feed-controls-shell {
  width: 100%;
  max-width: 100%;
}

#main-feed-shell.main-feed-page-shell .feed-controls-primary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 44px;
  border-bottom: 1px solid color-mix(in srgb, var(--feed-border) 58%, transparent);
}

#main-feed-shell.main-feed-page-shell .feed-controls-tabs-slot {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

#main-feed-shell.main-feed-page-shell .feed-controls-action-slot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 0;
}

#main-feed-shell.main-feed-page-shell .feed-search-open-btn,
#main-feed-shell.main-feed-page-shell .feed-search-close-btn {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--feed-border) 72%, transparent);
  background: color-mix(in srgb, var(--feed-panel) 82%, transparent);
  color: var(--feed-muted);
  border-radius: 999px;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  line-height: 1;
}

#main-feed-shell.main-feed-page-shell .feed-search-open-btn:hover,
#main-feed-shell.main-feed-page-shell .feed-search-close-btn:hover,
#main-feed-shell.main-feed-page-shell .feed-search-open-btn:focus-visible,
#main-feed-shell.main-feed-page-shell .feed-search-close-btn:focus-visible {
  border-color: color-mix(in srgb, var(--feed-primary) 42%, transparent);
  color: var(--feed-primary);
  outline: none;
}

#main-feed-shell.main-feed-page-shell .feed-search-open-btn[aria-expanded="true"] {
  background: color-mix(in srgb, var(--feed-primary) 16%, transparent);
  color: var(--feed-primary);
  border-color: color-mix(in srgb, var(--feed-primary) 34%, transparent);
}

#main-feed-shell.main-feed-page-shell .feed-search-wrap--expandable {
  display: none;
  margin-top: 8px !important;
}

#main-feed-shell.main-feed-page-shell .feed-controls-shell.is-search-open .feed-search-wrap--expandable {
  display: block;
}

#main-feed-shell.main-feed-page-shell .feed-search-group {
  min-height: 42px !important;
  padding: 4px 5px 4px 9px !important;
  border-radius: 999px !important;
}

#main-feed-shell.main-feed-page-shell .feed-search-close-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
}

#main-feed-shell.main-feed-page-shell .feed-content-tabs {
  width: 100%;
  max-width: 100%;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  overflow: visible !important;
}

#main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-indicator {
  display: none !important;
}

#main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-control,
#main-feed-shell.main-feed-page-shell .feed-content-tabs [data-segmented-control-control] {
  height: 44px !important;
  min-height: 44px !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

#main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-control::before,
#main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-control::after,
#main-feed-shell.main-feed-page-shell .feed-content-tabs [data-segmented-control-control]::before,
#main-feed-shell.main-feed-page-shell .feed-content-tabs [data-segmented-control-control]::after {
  display: none !important;
}

#main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-label {
  position: relative;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 6px !important;
  margin-right: 0 !important;
  border-radius: 0 !important;
  color: var(--feed-muted) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  letter-spacing: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  white-space: nowrap !important;
}

#main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-label::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 0;
  height: 2px;
  border-radius: 999px;
  background: transparent;
}

#main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-control[data-active="true"] .mantine-SegmentedControl-label,
#main-feed-shell.main-feed-page-shell .feed-content-tabs [data-segmented-control-control][data-active="true"] .mantine-SegmentedControl-label,
#main-feed-shell.main-feed-page-shell .feed-content-tabs input:checked + .mantine-SegmentedControl-label {
  color: var(--feed-primary) !important;
}

#main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-control[data-active="true"] .mantine-SegmentedControl-label::after,
#main-feed-shell.main-feed-page-shell .feed-content-tabs [data-segmented-control-control][data-active="true"] .mantine-SegmentedControl-label::after,
#main-feed-shell.main-feed-page-shell .feed-content-tabs input:checked + .mantine-SegmentedControl-label::after {
  background: var(--feed-primary);
}

#main-feed-shell.main-feed-page-shell .feed-order-segment {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  flex: 0 0 auto !important;
  padding: 2px !important;
  border-radius: 999px !important;
  background: color-mix(in srgb, var(--feed-panel) 70%, transparent) !important;
}

#main-feed-shell.main-feed-page-shell .feed-order-segment .mantine-SegmentedControl-label {
  min-height: 28px !important;
  height: 28px !important;
  padding: 0 12px !important;
  border-radius: 999px !important;
  font-size: 0.8rem !important;
  white-space: nowrap !important;
}

#main-feed-shell.main-feed-page-shell .feed-topic-wrap {
  margin-top: 12px !important;
  margin-inline: 0 !important;
  padding-inline: 0 !important;
  padding-bottom: 2px !important;
  scrollbar-width: none;
  /* Right-edge fade hints that the row scrolls horizontally. */
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 36px), transparent 100%);
}

#main-feed-shell.main-feed-page-shell .feed-topic-wrap::-webkit-scrollbar {
  display: none;
}

@media (any-hover: hover) and (any-pointer: fine) {
  #main-feed-shell.main-feed-page-shell .feed-topic-wrap,
  #main-feed-shell.main-feed-page-shell .feed-topic-wrap label {
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
  }
}

#main-feed-shell.main-feed-page-shell .feed-topic-wrap.is-dragging,
#main-feed-shell.main-feed-page-shell .feed-topic-wrap.is-dragging * {
  cursor: grabbing !important;
}

#main-feed-shell.main-feed-page-shell .feed-topic-chip-group,
#main-feed-shell.main-feed-page-shell #topic-filter-chips {
  gap: 8px !important;
}

#main-feed-shell.main-feed-page-shell .feed-topic-chip .mantine-Chip-label,
#main-feed-shell.main-feed-page-shell .feed-topic-chip label {
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 12px !important;
  border: 1px solid color-mix(in srgb, var(--feed-border) 70%, transparent) !important;
  background: color-mix(in srgb, var(--feed-panel) 76%, transparent) !important;
  color: var(--feed-subtitle) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  box-shadow: none !important;
}

#main-feed-shell.main-feed-page-shell .feed-topic-chip input:checked + .mantine-Chip-label {
  background: var(--feed-primary) !important;
  border-color: var(--feed-primary) !important;
  color: #ffffff !important;
}

#main-feed-shell.main-feed-page-shell .feed-chart-row {
  width: 100% !important;
  max-width: 100% !important;
  margin-top: 8px !important;
  padding: 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 36px), transparent 100%);
}

#main-feed-shell.main-feed-page-shell .feed-chart-row::-webkit-scrollbar {
  display: none;
}

#main-feed-shell.main-feed-page-shell .feed-chart-chip-group,
#main-feed-shell.main-feed-page-shell .feed-chart-chip-group > *,
#main-feed-shell.main-feed-page-shell .feed-chart-chip-group .mantine-ChipGroup-root,
#main-feed-shell.main-feed-page-shell #graph-type-select {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 8px !important;
  width: max-content !important;
  min-width: max-content !important;
  white-space: nowrap !important;
}

#main-feed-shell.feed-theme-dark .feed-topic-chip input:checked + .mantine-Chip-label {
  color: #111827 !important;
}

@media (max-width: 767px), (max-height: 600px) and (pointer: coarse) {
  /* Phones: tabs + search + sort stay on ONE row (user 2026-08-24) — the
     tabs compact and the sort select narrows instead of wrapping below. */
  #main-feed-shell.main-feed-page-shell .feed-controls-primary-row {
    gap: 6px;
    min-height: 44px;
  }

  #main-feed-shell.main-feed-page-shell .feed-controls-action-slot {
    gap: 6px;
  }

  /* if an extra-narrow phone still runs out of room, the tabs scroll in
     place instead of pushing the sort control off the row */
  #main-feed-shell.main-feed-page-shell .feed-controls-tabs-slot {
    overflow-x: auto;
    scrollbar-width: none;
  }

  #main-feed-shell.main-feed-page-shell .feed-controls-tabs-slot::-webkit-scrollbar {
    display: none;
  }

  /* the sort select carries inline widths (w=124 + section widths in
     layout.py) — !important beats the inline styles */
  #main-feed-shell.main-feed-page-shell .feed-order-select {
    width: 87px !important;
  }

  #main-feed-shell.main-feed-page-shell .feed-order-select .mantine-Select-input {
    font-size: 13px;
    padding-left: 8px !important;
    padding-right: 20px !important;
  }

  #main-feed-shell.main-feed-page-shell .feed-order-select .mantine-Select-section[data-position="left"] {
    display: none;
  }

  #main-feed-shell.main-feed-page-shell .feed-order-select .mantine-Select-section[data-position="right"] {
    width: 18px !important;
  }

  #main-feed-shell.main-feed-page-shell .feed-search-open-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }

  #main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-control,
  #main-feed-shell.main-feed-page-shell .feed-content-tabs [data-segmented-control-control],
  #main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-label {
    height: 44px !important;
    min-height: 44px !important;
  }

  #main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-label {
    padding: 0 6px !important;
    /* the 16px desktop label margin (zz_feed_redesign.css) overflows phones */
    margin-right: 0 !important;
    font-size: 14px !important;
  }

  #main-feed-shell.main-feed-page-shell .feed-topic-wrap {
    margin-inline: 0 !important;
    padding-inline: 0 !important;
  }

  #main-feed-shell.main-feed-page-shell .feed-topic-chip .mantine-Chip-label,
  #main-feed-shell.main-feed-page-shell .feed-topic-chip label {
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 12px !important;
    font-size: 13px !important;
  }
}

@media (max-width: 359px) {
  #main-feed-shell.main-feed-page-shell .feed-content-tabs .mantine-SegmentedControl-label {
    padding: 0 4px !important;
    font-size: 13px !important;
  }

  #main-feed-shell.main-feed-page-shell .feed-order-select {
    width: 79px !important;
  }

  #main-feed-shell.main-feed-page-shell .feed-order-select .mantine-Select-input {
    font-size: 12px;
  }

  #main-feed-shell.main-feed-page-shell .feed-search-open-btn {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
  }
}
